C++ virtual table layout of MI(multiple inheritance)

Well, first of all, I’ll remind everyone that the design of the solution to implement polymorphism is an ABI decision outside of the Standard. For example, MSVC and the Itanium ABI (followed by gcc, clang, icc, …) have different ways to implement this.

With that out of the way, I think that this is an optimization for lookup.

Whenever you have a Derived object (or one of its descendant) and lookup the mumble member, you do not need to actually find out the Base2 subobject but can directly act from the Base1 subobject (whose address coincides with Derived subobject, so no arithmetic involved).

Leave a Comment