For example:
Good question, I have to say.
With multiple inheritance, there are multiple pointers to multiple vtables in the derived class. Each vtable is used to tell the derived class how to act “kind of like” the respective superclass. This is why if there are multiple superclasses, then there must be multiple vtables.
In our example, there is a CA_vtable that permits a C object pretend to be an A object, and there is another BA_vtable that permits a C object pretend to be a B object.
In addition, each super? member has its matching derived_offset initialized at run-time. This way, given a pointer of any super class of an object, we’ll still be able to compute the address of the object as a derived class.
In our example, the struct definition for C is as follows:
When we initialize an object c of struct C, we need to do the following:
How should we initialize offset_m1 in _CA_vtable and offset_m2 in _CB_vtable?