- #include
-
- using namespace std;
- class Animal
- {
-
- public:
- string name;
- int weight;
- string color;
- string sex;
- public:
- Animal(){}
- Animal(string n,int w,string c,string s):name(n),weight(w),color(c),sex(s)
- {
-
- cout << "我是动物园的讲解员,下面由我来给大家介绍这里的东动物"<< endl;
- }
- //构造纯虚函数
- virtual void perfrom()
- {
-
- }
- void show()
- {
- cout << "name: "<< name<
- cout << "weight:" <
- cout << "color:"<< color<
- cout << "sex:"<< sex<
- }
-
-
-
-
- };
- class Lion:public Animal
- {
- private:
- string say;
- public:
- Lion(){}
- Lion (string n ,int w,string c,string s,string a):Animal(n,w,c,s),say(a)
- {
-
- }
-
- void perfrom()
- {
- cout << "Lion:我要表演狮子怒吼" << endl;
- }
- void show()
- {
- cout << "name: "<< name<
- cout << "weight:" <
- cout << "color:"<< color<
- cout << "sex:"<< sex<
- cout << "技能:say:"<< say <
- }
- };
- class Elephant:public Animal
- {
- private:
- string water;
- public:
- Elephant(){}
- Elephant(string n,int w,string c,string s,string wa):Animal(n,w,c,s),water(wa)
- {
-
- }
- void perfrom()
- {
-
- cout << "elephant:我要表演大象喷水" << endl;
- }
- void show()
- {
- cout << "name: "<< name<
- cout << "weight:" <
- cout << "color:"<< color<
- cout << "sex:"<< sex<
- cout << "技能:water:"<< water <
- }
-
- };
- class Monkey:public Animal
- {
- private:
- string eat;
- public:
- Monkey(){}
- Monkey(string n,int w,string c,string s,string e):Animal(n,w,c,s),eat(e)
- {
-
- }
-
- void perfrom()
- {
- cout << "monkey: 我要表演猴子吃桃" << endl;
- }
- void show()
- {
- cout << "name: "<< name<
- cout << "weight:" <
- cout << "color:"<< color<
- cout << "sex:"<< sex<
-
-
相关阅读:
树形DP
【Android入门】5、Broadcast 广播、Kotlin 的高阶函数、泛型、委托
THREE--demo8(文字)
数据结构学习笔记(第八章 排序-内部排序)
【老生谈算法】matlab实现LU分解算法源码——LU算法
独立站源码搭建,跨境独立站怎么搭建?
金仓数据库 KingbaseES PL/SQL 过程语言参考手册(10. 触发器)
7.关于线性回归模型的Q&A
最热门的跨考考研5大专业是哪些?
Maven - 3、详解maven解决依赖问题
-
原文地址:https://blog.csdn.net/m0_69894626/article/details/133798569