Advertisement

编程填空:统计动物数量

阅读量:

026:编程填空:统计动物数量

总时间限制:

1000ms

内存限制:

65536kB

描述

代码填空,使得程序能够自动统计当前各种动物的数量

复制代码
 #include <iostream>

    
 using namespace std;
    
 // 在此处补充你的代码
    
  
    
 void print() {
    
 	cout << Animal::number << " animals in the zoo, " << Dog::number << " of them are dogs, " << Cat::number << " of them are cats" << endl;
    
 }
    
  
    
 int main() {
    
 	print();
    
 	Dog d1, d2;
    
 	Cat c1;
    
 	print();
    
 	Dog* d3 = new Dog();
    
 	Animal* c2 = new Cat;
    
 	Cat* c3 = new Cat;
    
 	print();
    
 	delete c3;
    
 	delete c2;
    
 	delete d3;
    

全部评论 (0)

还没有任何评论哟~