Code: Select all
FooBase foo1 = new FooBase() ;
foo1.bar() ; //this works ok
FooSub foo2 = new FooSub() ;
foo2.bar() ; //this works ok
FooBase foo3 = new FooSub() ;
foo3.bar() ; //shouldn't this call FooSub::bar() instead
//of FooBase::bar() ?
BTW, if your using djgpp gcc. Use the support code on my site, and link libsupcxx.a between your kernel stub, and object files, and code for vtable will be enabled for inheritance to work correctly. You will get one undefined reference to __cxa_pure_virtual. From looking around the web for info, I've defined it as so,
Code: Select all
extern "C" void __cxa_pure_virtual (void)
{
k_panic("__cxa_pure_virtual called!") ;
}
Any ideas how I can find why virtual functions causes an invalid op code? I've found this out by having a default trap handler which prints out which exception had occurred.