设计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 ...
随机推荐
- LeetCode 572. 另一个树的子树 | Python
572. 另一个树的子树 题目来源:https://leetcode-cn.com/problems/subtree-of-another-tree 题目 给定两个非空二叉树 s 和 t,检验 s 中 ...
- P1666前缀单词
题目传送门点我传送 Ⅰ.字典树+树型DP 非常奇妙的一种解法 第一部分:构建树 先对来的单词读入,插入字典树 然后对于一颗字典树,其实是有很多无用边的,所以我们需要删去一些边 删去非单词节点和非单词节 ...
- 【HBase】协处理器是什么?又能干什么?怎么用?
目录 简单了解 官方帮助文档 协处理器出现的原因 协处理器的分类 Observer Endpoint Phoenix 协处理器的使用 加载方式 静态加载 动态加载 协处理器的卸载 协处理器Observ ...
- scala 隐式参数
def test(implicit name: String = "susu"): Unit ={ println(name);} 三种调用方法如下:test("dudu ...
- vue项目-打印页面中指定区域的内容(亲测有效!)
关于打印整个页面的,没什么好说的.今天我给大家分享一个打印指定区域的方法,你想打印哪里,就打印哪里! 我也是刚刚开始接触打印这一块功能的,然后当然是找度娘深入了解了一番啦,期间试了网上的各种方法,有的 ...
- [hdu4300] next数组的应用
题意:给你一个密文和明文的对应表以及一个密文+明文的字符串,明文可能只出现前面的一部分(也就是说是原明文的前缀),求最短的明文. 思路:首先密文的长度至少占到一半,所以先把那一半解密,问题转化为找一个 ...
- Golang遍历删除数组
Golang 做数字切片 package main import "fmt" /*遍历删除数组示例*/ func main() { //定义一个数组 a1 := []int{1, ...
- 关于fromdata的上传文件问题
<div <label>上传pdf</label> <input id="fileId" type="file" accep ...
- HTML简单的伪装与造假
利用浏览器制止台能简单的修改内容,致使其造成伪装. 打开网页控制台后,不要管那些眼花撩乱的代码,我们直接寻找控制台顶部的 Tab 栏 找到 Console 这个 Tab,点击它,把代码 documen ...
- linux-Curl error (37): Couldn't read a file:// file for file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-x86_64 [Couldn't open file /e tc/pki/rpm-gpg/RPM-GPG-KEY-fedora-x86_64]
在安装Python3-pip 的时候遇到 [root@localhost rpm-gpg]# yum install python3-pipFedora 31 - x86_64 - Updates - ...