?? p2-111.cpp
字號:
#include<iostream.h>
//定義一個含有static數(shù)據(jù)成員的類
class ex
{
static int num; //static數(shù)據(jù)成員
public:
ex() {num++;}
~ex() {num--;}
disp_count() {
cout<<"The current instances count:";
cout<<num<<endl;
}
};
int ex::num=0; //設置static數(shù)據(jù)成員的初值
//main()函數(shù)測試ex類
main()
{
ex a;
a.disp_count();
ex *p;
p=new ex;
p->disp_count();
ex x[10];
x[0].disp_count();
delete p;
a.disp_count();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -