2021-04-26
1.定义一个Cat类,拥有静态数据成员函数numOfCats,记录Cat的个体数目;静态函成员函数getNumOfCats(),读取numOfCats。设计程序测试这个类。
#include
using namespace std;
class Cat{
public:
Cat(int weight=0):weight(weight){numOfCats++;}
Cat(Cat &p){
weight=p.weight;
numOfCats++;}
~Cat(){numOfCats–;}
int g
原创
2021-04-26 23:07:34 ·
1214 阅读 ·
0 评论