概述
#include<iostream>
using namespace std;
class Base{
public:
int n;
Base(int i):n(i)
{
cout<<"Base "<<n<<" constructed"<<endl;
}
~Base(){
cout<<"Base "<<n<< " destructed"<<endl;
}
};
class Derived:public Base{
public:
Derived(int i):Base(i){
cout<<"Derived constructed"<<endl;
}
~Derived(){
cout<<"Derived destructed"<<endl;
}
};
class MoreDerived:public Derived{
public:
MoreDerived():Derived(1){
cout<<"MoreDerived constructed"<<endl;
}
~MoreDerived(){
cout<<"MoreDerived destructed"<<endl;
}
};
int main()
{
MoreDerived Obj;
return 0;
}
转载于:https://www.cnblogs.com/alfredsun/p/4467244.html
最后
以上就是冷傲吐司为你收集整理的【程序设计实习】笔记 6-005 间接基类的全部内容,希望文章能够帮你解决【程序设计实习】笔记 6-005 间接基类所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复