class A

{
char k[3];
public:
virtual void aa() {}
};
class B : public virtual A
{
char j[3];
public:
virtual void bb() {}
};
 
class C : public virtual B
{
char i[3];
public:
virtual void cc() {}
};
 
class D : public B, public C
{
char l[3];
virtual void dd() {}
};
 
int main (int argc, char *argv[]) {
cout << "A: " << sizeof(A) << endl
<< "B: " << sizeof(B) << endl
<< "C: " << sizeof(C) << endl
<< "D: " << sizeof(D) << endl;
return 0;
}
 
输出8,16,24,36
很奇怪的是最后一个输出,至今没想出为啥会是36。忘谁能帮我解答,不胜感激。