-->
当前位置:首页 > 题库

PROGRAMMING:What do animals like to eat

Luz5年前 (2021-05-10)题库428
1. Design a base animal class (animal), including private data members: animal number int num; And animal name string name; Public member function: getnum() is used to get its number, getname() is used to get its name, a pure virtual function eat() and a constructor.
2. Dog class dog and cat class cat are derived from animal class. Each class has its own constructor. These two classes are designed according to the output results, and the output test of the design class is completed in the main function
3. It is required that the virtual function eat() must be called by using the base class pointer in the main function
###Input format:
Enter two lines, each line is animal number num and animal name name, separated by a space.
###Output format:
Output two lines, each line shows the animal number num, animal name name and favorite food.
###Input example:
Here is a set of inputs. For example:
```in
1 golden hair
2 Persia
```
###Output example:
The corresponding output is given here. For example:
```out
No.1 golden hair gnaws bone
Persian No.2 eats small fish
```







answer:If there is no answer, please comment