#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类 代码参考的更多相关文章

  1. 设计Dog类 代码参考

    #include <iostream> #include <string> using namespace std; class Dog { private: string n ...

  2. 设计一个多功能的MyTime类 代码参考

    #include <iostream> #include <cstdio> using namespace std; class MyTime { private: int h ...

  3. 设计Person类 代码参考

    #include <iostream> using namespace std; class Trapezium { private: int x1,y1,x2,y2,x3,y3,x4,y ...

  4. 设计并测试Trapezium类 代码参考

    #include <iostream> using namespace std; class Trapezium { private: int x1,y1,x2,y2,x3,y3,x4,y ...

  5. 设计MyTime类 代码参考

    #include <iostream> #include <cstdio> using namespace std; class MyTime { private: int h ...

  6. 设计Weekday类 代码参考

    #include <iostream> using namespace std; class Weekday { private: int num; public: void SetDay ...

  7. 从Student类和Teacher类多重派生Graduate类 代码参考

    #include <iostream> #include <cstring> using namespace std; class Person { private: char ...

  8. 从Point类继承的Circle类 代码参考

    #include <iostream> #include <cstring> using namespace std; class Point { private: int x ...

  9. 一个基类Person的多个派生类 代码参考

    #include <iostream> #include <cstring> using namespace std; class Person { protected: ch ...

随机推荐

  1. Java面试题:抽象类和接口的区别

    1.abstract class 在 Java 语言中表示的是一种继承关系,一个类只能使用一次继承关系.但是,一个类却可以实现多个interface. 2.在abstract class 中可以有自己 ...

  2. ASP.NET Core 包管理工具(4)

    之前忘记介绍ASP.NET Core静态文件wwwroot了.再来补充一下.步骤比较简单在项目上右击添加文件夹输入文件名称 wwwroot就搞定了.这个文件主要是放置一些静态文件的,比如css.js. ...

  3. Spring官网阅读(十六)Spring中的数据绑定

    文章目录 DataBinder UML类图 使用示例 源码分析 bind方法 doBind方法 applyPropertyValues方法 获取一个属性访问器 通过属性访问器直接set属性值 1.se ...

  4. MinorGC前检查

  5. csu1617]强连通分量

    题意:定义域属于一个集合S={0,1,...,n-1},求S的子集个数,满足以子集的元素为定义域的函数P(x)的值域等于子集本身. 思路:以元素为点,x到P(x)连一条有向边,不难发现,如果有一个有向 ...

  6. [hdu3486]rmq+枚举优化

    题意:给n个数,求最小的段数,使得每一段的最大值之和大于给定的k.每一段的长度相等,最后若干个丢掉. 思路:从小到大枚举段数,如果能o(1)时间求出每一段的和,那么总复杂度是O(n(1+1/2+1/3 ...

  7. [codeforces-543B]bfs求最短路

    题意:给一个边长为1的无向图,求删去最多的边使得从a到b距离<=f,从c到d距离<=g,a,b,c,d,f,g都是给定的,求最多删去的边数. 思路:反过来思考,用最少的边构造两条从a到b, ...

  8. 2018-07-01 jq效果

    jq效果的实现方法: 1.基本 show(time) -> 显示:相当于display:block hide(time) -> 隐藏:相当于display:none toggle(time ...

  9. 检查点,Block块,参数化

    l 检查点:每次运行时检查服务器返回的数据是否正确,节省人工检查的时间(压测中数据传输次数过多,页面可能会产生传递混乱) l 检查点函数:web_find l 检查点类型:文本检查点:图片检查点 l  ...

  10. 搞懂:前端跨域问题JS解决跨域问题VUE代理解决跨域问题原理

    什么是跨域 跨域:一个域下的文档或脚本试图去请求另一个域下的资源 广义的跨域包含一下内容: 1.资源跳转(链接跳转,重定向跳转,表单提交) 2.资源请求(内部的引用,脚本script,图片img,fr ...