无聊
2015-09-11 18:57
148 查看
#include <iostream> #include <string> using namespace std; class pet{ public: int sum(int a,int b); void show(); pet(int x, string y); ~pet(); void setage(); void setname(); private: string name; int age; int adoptage; }; pet::pet(int x,string y):age(x),name(y){ cout<<"开始"<<endl; } pet::~pet(){ cout<<"再见"<<endl; } int pet::sum(int a, int b) { return (a+b); } void pet::setage() { int age; cin>>age; this->age = age; } void pet::setname() { string name; cin>>name; this->name = name; } void pet::show() { cout<<"请问宠物的年龄是:"<<endl; cout<<"姓名:"<<name<<endl; cout<<"年龄:"<<age<<endl; } int main() { pet dai(18,"蛋蛋"); dai.show(); cout<<"请问您的宠物的姓名是:"<<endl; dai.setname(); cout<<"请问您的宠物的年龄是:"<<endl; dai.setage(); dai.show(); return 0; }
相关文章推荐
- linux下tty,控制台,虚拟终端,串口,console(控制台终端)详解http://blog.csdn.net/liaoxinmeng/article/details/5004743
- iOS开发-------简单通讯录(UITableView和CoreData的应用)
- HTTP协议详解
- win2d绘制图片
- (4.3.1.15)android.app.FragmentManager 与 android.support.v4.app.FragmentManager带来的若干Error
- JNI(三)、java代码传递int、String、int[] 并 调用C 代码
- hdu 5162 Jump and Jump...(水题)
- RoboEarth 1
- php 常用的内置函数
- 【前端学习笔记】2015-09-11~~~~ js中ajax请求返回案例
- Leetcode:279Perfect Squares
- 多校联合第八场hdu5387Clock 最大公约数
- 《模式识别和机器学习》资源
- Centos7 安装kilo-4 controller(glance)
- opencv安装完成,测试时出现没有为opencv_core2410d.dll加载符号问题的解决
- 随机森林入门攻略(内含R、Python代码)
- 软件工程的实践项目的自我目标
- C语言中int到float的强制类型转换
- 关于火狐浏览器 如何 屏蔽 优酷等网站的 广告问题 OpenGG.Clean.Player (转载)
- mysql存储过程对900w数据进行操作测试