Do base and derived classes share a virtual table? When I applied for a job, some interviewers from famous Internet companies said yes with certainty. Although I told them that the pointer value pointing to the virtual table in the derived class object is different from the pointer value pointing to the virtual table in the base class object, so they should not share the same virtual table, the interviewer still said with certainty that they share the same virtual table. So I was a little confused and came here to find the answer.
It may depend on the implementation, but at least neither gcc nor clang let the base class and derived classes share vtable. There will be one vtable per class (which is then shared among all instances of the class). It would defeat the purpose of implementing runtime polymorphism by using vtables if there wasn't one vtable per class.