- #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<
-
-
相关阅读:
如何在idea中使用maven搭建tomcat环境
在Visual Studio Code中配置C++编译器的一般步骤
Linux高级IO ----- select
从零开始学YC-Framework之鉴权
【Oracle】Oracle系列之十一--PL/SQL
Spring基于Annotation装配Bean
申报高企的条件你真的满足了吗?
4.5 MongoDB 文档存储
ThreadLocal的简单理解
在实施 360 反馈流程之前要考虑的 6 个问题
-
原文地址:https://blog.csdn.net/m0_69894626/article/details/133798569
-
最新文章
-
沪漂五周年了:我越来越迷茫了
Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
MySQL-Seconds_behind_master的精度误差
[MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
Agent OS :五种驯服不确定性的范式
PortSwigger SQL注入LAB11
数据库即时编译JIT
[Begin]AI Learn Data Day 0
深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU