设计带构造函数的Dog类 代码参考
#include <iostream>
#include <string> using namespace std; class Dog
{
private:
string name;
int age;
char sex;
double weight;
public:
Dog(string,int,char,double);
void GetName(){cin>>name;return;}
void GetAge(){cin>>age;return;}
void GetSex(){cin>>sex;return;}
void GetWeigth(){cin>>weight;return;}
void speak(){cout<<"Arf!Arf!"<<endl;return;}
void show()
{
cout<<name<<endl;
cout<<age<<endl;
cout<<sex<<endl;
cout<<weight<<endl;
return;
}
}; Dog::Dog(string name, int age, char sex, double weight)
{
this->name=name;
this->age=age;
this->sex=sex;
this->weight=weight;
} int main()
{
string name;
int age;
char sex;
double weight;
cin>>name>>age>>sex>>weight;
Dog one(name,age,sex,weight);
one.show();
one.speak();
return ;
}
设计带构造函数的Dog类 代码参考的更多相关文章
- 设计Dog类 代码参考
#include <iostream> #include <string> using namespace std; class Dog { private: string n ...
- 设计一个多功能的MyTime类 代码参考
#include <iostream> #include <cstdio> using namespace std; class MyTime { private: int h ...
- 设计Person类 代码参考
#include <iostream> using namespace std; class Trapezium { private: int x1,y1,x2,y2,x3,y3,x4,y ...
- 设计并测试Trapezium类 代码参考
#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 ...
- 从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 ...
随机推荐
- 在linux上搭建nacos集群(步骤详细,linux小白也搞得定)
(1)nacos官网:https://github.com/alibaba/nacos/releases/tag/1.2.1下载nacos安装包到window本地(后缀为tar.zip) (2)在li ...
- andorid jar/库源码解析
前言 本篇作为开篇,会大体上说明,需要解读源码的,类库,或者jar. 序 原本,类库和jar的系列准备写到逆向系列课程的,但是那个东西,在写了两篇,就没有后续了,现在也不知道从哪里开始了, 只能等后期 ...
- mac下xampp访问php显示403错误
错误描述 New xampp security concept: Access Forbidden Error 403 错误分析和解决 403就是我们访问的时候,被安全策略拒绝了,解决方法 找到文件 ...
- 一文教你快速学会在matlab的simulink中调用C语言进行仿真
本文介绍如何在matlab的simulink中嵌入C语言进行多输入多输出的仿真:matlab版本位2015b: 创作不易,如果本文帮到了您: 如果本文帮到了您,请帮忙点个赞
- python入门及数字、字符串类型
目录 python开发框架 开发 1. 开发语言 2. 语言比对 3. python安装 4. Python开发IDE:pycharm ,eclipse python入门 1. 第一句Python 2 ...
- @RequestParam和@RequestBody和@PathVariable用法小结
@RequestParam 使用@RequestParam接收前段参数比较方便,前端传参的URL: url = "${ctx}/main/mm/am/edit?Id=${Id}&na ...
- SpringData:关联查询
一.查询方式 1.导航式查询 使用“对象.属性” 进行查询:对于多的查询, 默认就是延迟加载,添加注解@Transactional 在OneToMany 注解中需要添加属性 fetch:值:F ...
- (数据科学学习手札83)基于geopandas的空间数据分析——geoplot篇(下)
本文示例代码.数据及文件已上传至我的Github仓库https://github.com/CNFeffery/DataScienceStudyNotes 1 简介 在上一篇文章中我们详细学习了geop ...
- UEFI Shell --常用命令解释
UEFI Shell解释 UEFI Shell 是一个提供用户和UEFI系统之间的接口,进入UEFI Shell可以对计算机系统进行配置 命令解释: 单独的help就可以输出所有指令,不做特殊说明,内 ...
- 2018-08-27 jq筛选选择器
筛选选择器:为了辅助选择器更简便.快速的找到元素: 1.过滤 eq(n) -> 第n个元素(从零开始) $('h1').eq(2) // 第三个h1 first() -> 第一个元素 la ...