Why do we need a virtual table?

Without virtual tables you wouldn’t be able to make runtime polymorphism work since all references to functions would be bound at compile time. A simple example struct Base { virtual void f() { } }; struct Derived : public Base { virtual void f() { } }; void callF( Base *o ) { o->f(); } … Read more

What is the first (int (*)(…))0 vtable entry in the output of g++ -fdump-class-hierarchy?

Those are the offset-to-top (needed for multiple inheritence) and typeinfo (RTTI) pointers. From the Itanium ABI (you are not using the Itanium compiler, but their description of this is really good): The offset to top holds the displacement to the top of the object from the location within the object of the virtual table pointer … Read more