Well, looking at the generated code, the first example has this memory layout:
| Derived::vtable | Base1::vtable | Base2::vtable |
The second has this layout:
| Derived::vtable | 00 00 00 00 | Base1::vtable | 00 00 00 00 | | Base2::vtable |
What zeros I do not know. They do not fill out, since the filling remains uninitialized with the help of CCCCCCCC . Perhaps they are used as counters or flags when deleting virtual subobjects, and when you add a destructor, these fields are added to the class. I was unable to distinguish them from 00000000 .
In any case, you can add this to your question: why, when I create a virtual destructor, then the layout becomes
| Derived::vtable | 00 00 00 00 | Base1::vtable | 00 00 00 00 | | Base2::vtable | padding |
(24 bytes)?
source share