Possible Duplicate:
Understanding the vtable entries
Using g++ version 4.6.3, 64-bit machine . I know compiler is free to implement virtual functions any way it wants. I want to know what happened here.
My class:
#include <iostream>
class test
{
public:
virtual void func(){std::cout<<"in class test";}
};
int main()
{
test obj;
obj.func();
return 0;
}
Looking at virtual table generated by compiler,
Vtable for test
test::_ZTV4test: 3u entries
0 (int (*)(...))0 (<---- what is this? )
8 (int (*)(...))(& _ZTI4test)
16 (int (*)(...))test::func
At offset 8 it is RTTI
At offset 16 it is entry for virtual function.
My question is why is there entry for NULL at offset 0 or in other words what is the purpose of first entry?
P.S. I thought this could be related to alignment, but then I added more virtual functions but RTTI entry was still at offset 8.