链接:https://pan.baidu.com/s/1KayCjn6Vem9YFucS8lpCFg?pwd=1688
提取码:1688
设计一个动物类:动物有一个name成员,另外有三个函数sleep(), eat(), play();
从动物这个类派生出狗类和猫类,在对应的三个函数中实现输出如下信息的功能:
dog(or cat) (name) is sleepping...!
dog(or cat) (name) is eatting...!
dog(or cat) (name) is playing! wangwang...(miao...)
从动物类派生出一个人类:人类有name,age成员,另外还有play_with()这样一个函数.
//****************************************
#include <iostream>
#include <cstring>
using std::cin;
using std::cout;
using std::endl;
class Animal{
private:
char *name;
public:
Animal(char *str = "XXX"){
name = new char[strlen(str)+1];
if(name)
strcpy(name,