设计Dog类 代码参考
#include <iostream>
#include <string> using namespace std; class Dog
{
private:
string name;
int age;
char sex;
double weight;
public:
void GetName(){cin>>name;return;}
void GetAge(){cin>>age;return;}
void GetSex(){cin>>sex;return;}
void GetWeight(){cin>>weight;return;}
void ShowMyDog(){
cout<<"It is my dog."<<endl;
cout<<"Its name is "<<name<<'.'<<endl;
cout<<"It is "<<age<<" years old."<<endl;
if(sex=='m') cout<<"It is male."<<endl;
else cout<<"It is female."<<endl;
cout<<"It is "<<weight<<" kg."<<endl;
return;
}
}; int main()
{
Dog one;
one.GetName();
one.GetAge();
one.GetSex();
one.GetWeight();
one.ShowMyDog();
return ;
}
设计Dog类 代码参考的更多相关文章
- 设计带构造函数的Dog类 代码参考
#include <iostream> #include <string> using namespace std; class Dog { private: string n ...
- 设计Person类 代码参考
#include <iostream> using namespace std; class Trapezium { private: int x1,y1,x2,y2,x3,y3,x4,y ...
- 设计MyTime类 代码参考
#include <iostream> #include <cstdio> using namespace std; class MyTime { private: int h ...
- 设计Weekday类 代码参考
#include <iostream> using namespace std; class Weekday { private: int num; public: void SetDay ...
- 设计一个多功能的MyTime类 代码参考
#include <iostream> #include <cstdio> using namespace std; class MyTime { private: int h ...
- 设计并测试Trapezium类 代码参考
#include <iostream> using namespace std; class Trapezium { private: int x1,y1,x2,y2,x3,y3,x4,y ...
- 从Student类和Teacher类多重派生Graduate类 代码参考
#include <iostream> #include <cstring> using namespace std; class Person { private: char ...
- 从Point类继承的Circle类 代码参考
#include <iostream> #include <cstring> using namespace std; class Point { private: int x ...
- 一个基类Person的多个派生类 代码参考
#include <iostream> #include <cstring> using namespace std; class Person { protected: ch ...
随机推荐
- kafka可插拔增强如何实现?
导弹拦截,精准防御. 背景 拦截器:在不修改应用程序业务逻辑的情况下,一组基于事件的可插拔的逻辑处理链: 类比springMVC的拦截器: 这些都是通过配置拦截器,插入到应用程序中,实现可插拔的修改业 ...
- 2019国防科大校赛 B Escape LouvreⅡ
https://ac.nowcoder.com/acm/contest/878/B 这个题目是一个网络流,但是建图却没有那么好建,首先我们都会把每一个人与源点相连,每一个洞口和汇点相连. 然后人和洞口 ...
- node常用插件使用
1.nodemon 用于热更新,随时监控文件的变化 安装npm i -g nodemon 使用nodemon index.js 2.nvm nvm用于nodejs版本管理,我们在开发过程中,不同的项目 ...
- 拒绝老土!暗黑风格半透平面化主题—InfinityFreedom正式发布
经常听到“路由器界面土点就土点吧,凑合能用就成.” 诚然,路由器重要的是功能,但为什么要辣眼睛呢? 拯救喜欢折腾的你,抢救干涩的眼球,原创OpenWrt主题Infinity Freedom正式发布! ...
- 软路由OpenWrt(LEDE)2020.4.6编译 UnPnP+NAS+多拨+网盘+DNS优化
近期更新:2020.04.06编译-基于OpenWrt R2020.3.19版本,源码截止2020.04.06. 2020.04.06更新记录: 以软件包形式提供ServerChan(微信推送) ...
- 【Kafka】Kafka集群基础操作!新手上路必备~
目录 bin目录 Topic命令概览 创建Topic 查看Topic 描述Topic Producer生产数据 Consumer消费数据 增加topic分区数 增加配置 删除配置 删除Topic 所有 ...
- JAVA知识总结(三):继承和访问修饰符
今天乘着还有一些时间,把上次拖欠的面向对象编程三大特性中遗留的继承和多态给简单说明一下.这一部分还是非常重要的,需要仔细思考. 继承 继承:它是一种类与类之间的关系,通过使用已存在的类作为基础来建立新 ...
- Openwrt:mtd/mtd_write烧写固件
文章目录 1 查看当前系统分区信息 2 备份固件firmware 3 恢复固件firmware 4 备份恢复Openwrt路由器配置 5 恢复Openwrt路由器默认设置 6 刷新路由器固件 比较简单 ...
- 我去,你竟然还不会用 synchronized
二哥,离你上一篇我去已经过去两周时间了,这个系列还不打算更新吗?着急着看呢. 以上是读者 Jason 发来的一条信息,不看不知道,一看真的是吓一跳,上次我去是 4 月 3 号更新的,离现在一个多月了, ...
- SpringBoot基础实战系列(三)springboot单文件与多文件上传
springboot单文件上传 对于springboot文件上传需要了解一个类MultipartFile ,该类用于文件上传.我此次使用thymeleaf模板引擎,该模板引擎文件后缀 .html. 1 ...