思维导图 代码 #include <iostream> using namespace std; //封装一个 讲解员 类 class Animal { public: Animal() { } virtual void perform() { cout << " " << endl; } }; //封装一个 狮子 类 class Lion:public Animal { public: Lion() { } void perform() { Animal::perform(); cout << "动物:狮子" <<" 表演:钻火圈" << endl; } }; //封装一个 鹦鹉 类 class Parrot:public Animal { public: Parrot() { } void perform() { Animal::perform(); cout << "动物:鹦鹉" <<" 表演:说人话" << endl; } }; //封装一个 鲸鱼 类 class Whale:public Animal { public: Whale() { } void perform() { Animal::perform(); cout << "动物:鲸鱼" <<" 表演:喷水" << endl; } }; //定义一个行为函数 void fun(Animal &p) { p.perform(); } int main() { Lion l1; Parrot p1; Whale w1; fun(l1); fun(p1); fun(w1); return 0; } 结果