Reputation:
If I have one base class and I derive 10 different concrete derived classes from it then will each and every concrete derived class have a different vtable?
Upvotes: 1
Views: 1286
Reputation: 792039
If the base class or all of the derived classes have any virtual functions, then yes, usually. Why is it important?
Two classes can only share a vtable if they have an indentical set of virtual functions. So a derived class can only share a vtable with a base class if it doesn't override any virtual functions.
A derived class can't share a vtable with any other derived class unless they both don't override any functions of the same base class as - even if implemented in the same way - the member functions of one derived class are a different type from the member functions of a different derived class.
Upvotes: 4
Reputation: 13028
Depends on whether your derived classes override/declare any virtual methods.
Upvotes: 0