[C++] 纯文本查看 复制代码#include
using namespace std;
class AB
{
public:
int b;
AB(int b)
{
this->b = b;
cout << "构造函数AB()执行了" <
}
~AB()
{
cout << "析构函数~AB()执行了" <
}
};
class AC
{
public:
int c;
AC(int c)
{
this->c = c;
cout << "构造函数AC()执行了" <
}
~AC()
{
cout << "析构函数~AC()执行了" <
}
};
//多继承派生类
class ABC :public AB,public AC
{
public:
ABC():AB(3),AC(4)//初始化列表
{
cout << "构造函数ABC()执行了" <
}
~ABC()
{
cout << "析构函数~ABC()执行了" <
}
};
int main(int argc,char *argv[])
{
ABC *pABC = new ABC();
delete pABC;
system("pause");
return 0;
}