虚基类多出来的空间问题
#include<iostream>using namespace std;
class sample3
{
public:
int a;
int d;
};
class sample1:virtual public sample3
{
public:
int b;
};
class sample2:virtual public sample3
{
public:
int c;
};
class sample:public sample1,public sample2
{
};
int main()
{
sample obj;
cout<<sizeof(sample1)<<endl;
cout<<sizeof(sample)<<endl;
}
这个程序输出结果是16和24,sample1类多出的4个字节用来存放什么?还有sample多出的8个字节用来存放什么?