前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >动物类及修改-C++

动物类及修改-C++

作者头像
WindCoder
发布2018-09-19 18:13:29
4490
发布2018-09-19 18:13:29
举报
文章被收录于专栏:WindCoderWindCoder
代码语言:javascript
复制
/*
功能:动物类
日期:2013-10-12
*/
#include <iostream>
#include <string>
using namespace std;
class Animal
{
public:
    Animal(string aName,string aGender,string aColor,string aVoice);
	~Animal();
    void rest();
    void Display()const;
private:
	string m_aName;
	string m_aGender;
	string m_aColor;
	string m_aVoice;
};
Animal::Animal(string aName="Dog",string aGender="Male",string aColor="Yellow",string aVoice="wangwang"):
m_aName(aName),m_aGender(aGender),m_aColor(aColor),m_aVoice(aVoice){};
Animal::~Animal()
{
};
void Animal::Display()const
{
	cout<<"Now animal information is:"<<endl;
	cout<<"Animal name:"<<m_aName<<endl;
	cout<<"Animal gender:"<<m_aGender<<endl;
	cout<<"Animal color:"<<m_aColor<<endl;
	cout<<"Animal Voice:"<<m_aVoice<<endl;
	cout<<"What do you want to reset:(1.name;2.gender;3.color;4.voice;5.exit)";
}
void Animal::rest()
{
	int choice;
	do
	{
		Display();
		cin>>choice;
		switch(choice)
		{
		case 1:
			cout<<"Reset name:";
			cin>>m_aName;
			break;
		case 2:
			cout<<"Reset gender:";
			cin>>m_aGender;
			break;
		case 3:
			cout<<"Reset color:";
			cin>>m_aColor;
			break;
		case 4:
			cout<<"Reset voice:";
			cin>>m_aVoice;
			break;
		case 5:
			break;

		}
	}while(choice!=5);
}
int main(void)
{
    Animal animal;
	animal.rest();
	system("pause");
	return 0;
}
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2014-08-19,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档