5.19

发布时间 2023-05-19 21:01:25作者: 张佳木

#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;

    }