?? 7_66.cpp
字號:
#include <iostream.h>
class cB
{
public:
cB();
cB(int);
~cB();
int get(){return B_value;}
protected:
int B_value;
};
class cA
{
public:
cA(int,int);
~cA();
int getcA(){ return b.get();}
protected:
int a;
cB b;
};
cB::cB()
{ B_value=1;
cout<<"construct cB. B_value="<<B_value<<endl;
}
cB::cB(int v)
{
B_value=v;
cout<<"construct cB. B_value="<<B_value<<endl;
}
cB::~cB()
{ cout<<"destruct cB. B_value="<< B_value<<endl;
}
cA::cA(int v1,int v2)
{ a=v1;
cB b(v2); //調用cB的有參構造函數
cout<<"construct cA. a="<<a<<endl;
}
cA::~cA()
{ cout<<"destruct cA."<<endl;
}
void main()
{ cA a(5,10);
cout<<a.getcA()<<endl;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -