I have some questions about the object size with virtual.
1) virtual function
class A {
public:
int a;
virtual voi
This obviously depends on the compiler implementation. Anyway I think that I can sum up the following rules from the implementation given by a classic paper linked below and which gives the number of bytes you get in your examples (except for class D which would be 36 bytes and not 32!!!):
The size of an object of class T is:
So we have to answer another question: When does a class need ANOTHER v-table?
The End of the rules (which I think can be applied to match what Terry Mahaffey has explained in his answer) :)
Anyway my suggestion is to read the following paper by Bjarne Stroustrup (the creator of C++) which explains exactly these things: how many virtual tables are needed with virtual or non virtual inheritance... and why!
It's really a good reading: http://www.hpc.unimelb.edu.au/nec/g1af05e/chap5.html