?? 7_6.cpp
字號:
//7_6.cpp
#include <iostream>
using namespace std;
class B1 //基類B1聲明
{
public:
B1(int i) {cout<<"constructing B1 "<<i<<endl;} //B1的構(gòu)造函數(shù)
~B1() {cout<<"destructing B1 "<<endl;} //B1的析構(gòu)函數(shù)
};
class B2 //基類B2聲明
{
public:
B2(int j) {cout<<"constructing B2 "<<j<<endl;} //B2的構(gòu)造函數(shù)
~B2() {cout<<"destructing B2 "<<endl;} //B2的析構(gòu)函數(shù)
};
class B3 //基類B3聲明
{
public:
B3(){cout<<"constructing B3 *"<<endl;} //B3的構(gòu)造函數(shù)
~B3() {cout<<"destructing B3 "<<endl;} //B3的析構(gòu)函數(shù)
};
class C: public B2, public B1, public B3 //派生類C聲明
{
public:
C(int a, int b, int c, int d):B1(a),memberB2(d),memberB1(c),B2(b){}
//派生類構(gòu)造函數(shù)定義
private:
B1 memberB1;
B2 memberB2;
B3 memberB3;
};
void main()
{ C obj(1,2,3,4);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -