设计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 ...
随机推荐
- java程序猿面试系列之jvm专题
前言 因为疫情的影响,现在都变成金五银六了.为了方便大家,在此开一个程序猿面试系列.总结各大公司所问的问题,希望能够帮助到大家,适合初中级java程序猿阅读. 1. Java类实例化时,JVM执行顺序 ...
- 【Java新特性】Lambda表达式典型案例,你想要的的都在这儿了!!
写在前面 不得不说,有些小伙伴的学习热情真高,学完了Lambda表达式的语法,想来几个典型案例再强化下.于是问冰河能否给几个Lambda表达式的典型使用示例.于是乎,便有了这篇文章. 案例一 需求 调 ...
- js循环数组方法some和forEach怎么用
forEach不支持break和return.一般普通循环都是用forEach ar arr1=["aa","bb","aa"," ...
- STL下<algorithm>下的sort函数
定义: sort函数用于C++中,对给定区间所有元素进行排序,默认为升序,也可进行降序排序.sort函数进行排序的时间复杂度为nlog2n,比冒泡之类的排序算法效率要高,sort函数包含在头文件为#i ...
- 内容安全策略(CSP)详解
1.背景 1.1.同源策略 网站的安全模式源于"同源策略",web浏览器允许第一个web页面中的脚本访问页面中的数据,但前提是两个web页面具有相同的源.此策略防止一个页面的恶意脚 ...
- 初识spring boot maven管理--HelloWorld
配置文件配置好 了之后可以进行第一个例子的编写了! @Controller @EnableAutoConfiguration() public class SampleController { pri ...
- 改进Page Object公共方法封装(base_page)
import os from time import sleep from selenium import webdriver from selenium.webdriver.common.by im ...
- java web基础
WEB基础 C/S:即服务器-客服机(Client-Server)结构.C/S结构通常采用两层结构,服务器负责数据的管理,客户机负责完成与用户的交互任务.客户通过局域网与服务器相连,接受用户的请求,并 ...
- vue + typescript,定义全局变量或者方法
众所周知,在 vue中,如果想定义一个全局变量的方法很简单,直接在 vue的原型上挂载属性或者方法即可. 但是,加上了typescript之后, Vue.prototype.$xxx = xxx 这 ...
- CS0016: 未能写入输出文件“c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\ad888a2
http://wenwen.sogou.com/z/q445150234.htm IIS_USRS