I copied and pasted your code into the Arduino IDE (1.0.5). I had to add a #endif statement to the .h file, and had to change the #include statement in the sketch, that includes the I2CH.h file, to use "" instead of <>. When I did that, I got one error:
Binary sketch size: 2,616 bytes (of a 258,048 byte maximum)
Using the class name in the method name is not standard practice. The method should be called begin().
//I2CH.cpp
#include "I2CH.h"
void I2CH::aaa()
{
Wire.onReceive(receiveEvent);
}
void I2CH::receiveEvent(int howMany)
{
while( Wire.available()>0) // loop through all but the last
{
char c = Wire.read(); // receive byte as a character
}
}
When the Wire class receives some data, you want it to call the receiveEvent() function. For which instance of the class?
Suppose that you have
I2CH one;
I2CH two;
I2CH three;
and some data comes on on the I2C pins. Which instance should deal with the data?
It does not matter AT ALL that you only plan to have one instance of the class. The compiler can not know what your plans are.
The receiveEvent() method must be static (a class function, rather than a member function) in order to be used that way.
Of course, that will cause a bunch of other problems, because the static method belongs to the class, not an instance of the class. It will have the same problem knowing which instance of the class gets the data.