【程序设计实习】笔记 6-005 间接基类

#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;
} 

posted @ 2015-04-13 14:35  夜歌乘年少  阅读(211)  评论(0编辑  收藏  举报