Inheritance

Hi all,

I'm just wondering if anybody used inheritance with the avr-g++ compiler or Arduino. Is it supported?

I tried to create a simple inheritance structure so I could "speak" to my Sensor classes via a generic sensor interface, but did not yet managed to succesfully compile it. I'm getting strange undefined references. Still figuring out the real cause though.

Inheritance should work, although things like virtual functions, new and delete, etc, might not.

Inheritance works fine, although I'm curious about the remark concerning virtual operators.

Thanks for the answer! I was already worried C++ support was reduced to simple class containers and no basic OO techniques.

I did try to create a pure virtual interface, but it failed with something like: "unable to vlookup ... in vtable".

I don't have a machine with avr-g++ at hand so I cannot give you the exact error unfortunately. Will try a simple inheritance structure tonight.

It seems that declaring a destructor virtual (Something that is highly adviced when iplementing inheritance in C++), I get the following compile error:

o: In function ~<Class name>': undefined reference to operator delete(void*)

I think a virtual destructor requires the delete operator which in his turn requires stdlibc++ wich is not supported by avr-g++… :-/

o: In function ~<Class name>': undefined reference to operator delete(void*)

I think a virtual destructor requires the delete operator which in his turn requires stdlibc++ wich is not supported by avr-g++… :-/

From the hopefully better late than never file, this may be of use: avr-c++ micro how-to.

–Phil.