マルチ継承時のvirtualの使用

1637 ワード

#include
using namespace std;

class A
{
public:
    int a;
};

class B:virtual public A
{
public:
    int b;
};

class C:  public A
{
public:
    int c;      
};

class D: public B, public C
{   
public:
    int s;

};

int main()
{
    A a;
    B b;
    C c;
    D d;
    cout << sizeof(a) << endl;
    cout << sizeof(b) << endl;
    cout << sizeof(c) << endl;
    cout << sizeof(d) << endl;
    return 0;
};
4
16
8
32