#include <iostream>
using namespace std;
/*---------------------------------
12 多重继承的构造与析构
---------------------------------*/
class a
{
public:
a() {cout<<"构造a"<<endl;}
~a(){cout<<"析构a"<<endl;}
};
class b
{
public:
b() {cout<<"构造b"<<endl;}
~b(){cout<<"析构b"<<endl;}
};
class c
{
public:
c() {cout<<"构造c"<<endl;}
~c(){cout<<"析构c"<<endl;}
};
class d:public a,public b,public c //像堆栈
{
};
int main()
{
d com;
return 0;
}
运行结果:
构造a
构造b
构造c
析构c
析构b
析构a
Press any key to continue
C++ 继承 5--多重继承的构造与析构
最新推荐文章于 2024-02-27 09:36:37 发布