5_7.cpp
来自「湖南大学ACM-OJ的部分题目代码」· C++ 代码 · 共 23 行
CPP
23 行
#include<iostream>
using namespace std;
class cat
{
private:
static int HowManyCats;
public:
cat(){HowManyCats++;}
~cat(){HowManyCats--;}
static int GetHowMany(){return HowManyCats;}
};
int cat::HowManyCats=0;
void main()
{
cout<<cat::GetHowMany()<<endl;
cat cat1;
cout<<cat::GetHowMany()<<endl;
cat cat2;
cout<<cat::GetHowMany()<<endl;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?