5.19

#include<iostream>

using namespace std;

#include<string>

class animal {

public:

    void show() {

         cout << "Animal"<<" " << "名称:" << name << " " << "年龄:" << age << endl;

    }

protected:

    string name;

    int age;

};

class fish : virtual public animal {

public:

    void show() {

         cout << "Fish" << " " << "名称:" << name << " " << "年龄:" << age <<"速度:"<<velocity<< endl;

    }

protected:

    int velocity;

};

class beast : virtual public animal {

public:

    void show() {

         cout << "Beast" << " " << "名称:" << name << " " << "年龄:" << age << "食量:" << appetite << endl;

    }

posted @ 2023-05-19 20:53  张佳木  阅读(47)  评论(0)    收藏  举报