#include <iostream>
using namespace std;
class Mother
{
public:
Mother()
{
cout<<"mother:no parameters"<<endl;
}
Mother(int a)
{
cout<<"mother:int parameters"<<endl;
}
};
class Daughter:public Mother
{
public:
Daughter(int a)//没有指定调用主类的构造函数
{
cout<<"daughter:int parameters"<<endl;
}
};
class Son:public Mother
{
public:
Son(int a):Mother(a)//调用被指定的析构函数
{
cout<<"son:int parameters"<<endl;
}
};
int main()
{
Daughter dau(2);
Son so(2);
getchar();
return 0;
}
C++继承后的析构函数的调用
最新推荐文章于 2020-12-17 01:05:15 发布