标签:
程序示例
1 #include <iostream> 2 using namespace std; 3 class a 4 { 5 public: 6 a(){cout<<"构造a"<<endl;} 7 ~a(){cout<<"析构a"<<endl;} 8 }; 9 class b 10 { 11 public: 12 b(){cout<<"构造b"<<endl;} 13 ~b(){cout<<"析构b"<<endl;} 14 }; 15 class c 16 { 17 public: 18 c(){cout<<"构造c"<<endl;} 19 ~c(){cout<<"析构c"<<endl;} 20 }; 21 class d 22 { 23 public: 24 d(){cout<<"构造d"<<endl;} 25 ~d(){cout<<"析构d"<<endl;} 26 }; 27 class e 28 { 29 public: 30 e(){cout<<"构造e"<<endl;} 31 ~e(){cout<<"析构e"<<endl;} 32 }; 33 class f:public a,public b,public c,public d,public e//构造和销毁类的顺序与此顺序有关 34 {}; 35 void main() 36 { 37 f a; 38 }
结果演示
标签:
原文地址:http://www.cnblogs.com/table/p/4719472.html