// viture.cpp : Defines the entry point for the console application.
//virtual 多重继承和虚析构
#include "stdafx.h"
#include <iostream>
using namespace std;
class A
{
public:
int m_i;
A()
{
cout<<"构造A"<<endl;
}
~A()
{
cout<<"析构A"<<endl;
}
};
class B: public A
{
public:
int m_j;
B()
{
cout<<"构造B"<<endl;
}
~B()
{
cout<<"析构B"<<endl;
}
};
class C: public A
{
public:
int m_k;
C()
{
cout<<"构造C"<<endl;
}
~C()
{
cout<<"析构C"<<endl;
}
};
class D: public B, public C
{
public:
D()
{
cout<<"构造D"<<endl;
}
~D()
{
cout<<"析构D"<<endl;
}
};
int main(int argc, char* argv[])
{
A *pa = new D();
delete pa;
D *pd = new D();
delete pd;
cout<<sizeof(D)<<endl;
getchar();
return 0;
}
1.上面默认打印什么?D的大小?
2.在全部析构函数加virtual 打印什么?D的大小?
3.在继承的public加vitual 打印什么?D的大小?
4.加上2和3的条件打印什么?D的大小?