number--; } };intAnimal::number=0;//初始化classDog:publicAnimal{public:staticintnumber;//狗的数量Dog()//构造函数{ number++; }~Dog()//析构函数{ Dog::number--; } };intDog::number=0;//初始化classCat:publicAnimal{public:staticintnumber;//狗的数量Cat() { number++; }~Cat() { Cat...
1#include <iostream>2usingnamespacestd;3classAnimal{4public:5staticintnumber;6Animal(/*int num = 1*/){}7virtual~Animal(){--Animal::number;}8};9intAnimal::number =0;1011classDog:publicAnimal{12public:13staticintnumber;14Dog(intnum =1){15Animal::number = Animal::number +num;16Dog::...
003:编程填空:统计动物数量 https://blog.csdn.net/lily_prince/article/details/80509426