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

学生类Student之学生信息-C++

作者头像
WindCoder
发布2018-09-19 18:23:38
1.3K0
发布2018-09-19 18:23:38
举报
文章被收录于专栏:WindCoderWindCoder

先将以前的代码贴完,让电脑腾出点空间

功能:输入及输出学生姓名、年龄、性别

代码语言:javascript
复制
/*
功能:设计学生类Student
日期:2013-10-19
*/
#include <iostream>
#include <string>
using namespace std;

class Student
{
public:
	Student(string aName,string aAge,string aSex);

	~Student();
	string getName()const;
	string getAge()const;
	string getSex()const;
	void setName(string aName);
	void setAge(string aAge);
	void setSex(string aSex);
private:
	string m_aName;
	string m_aAge;
	string m_aSex;
};
Student::Student(string aName=NULL,string aAge=NULL,string aSex=NULL):
m_aName(aName),m_aAge(aAge),m_aSex(aSex){};
Student::~Student(){};
string Student::getName()const
{
	return m_aName;
}
string Student::getAge()const
{
	return m_aAge;
}
string Student::getSex()const
{
	return m_aSex;
}
void Student::setName(string aName)
{
     m_aName = aName;
}
void Student::setAge(string aAge)
{
	m_aAge = aAge;
}
void Student::setSex(string aSex)
{
	m_aSex = aSex;
}
int main(void)
{

   int n=5;
   string name,age,sex;
   Student student;
   cout<<"请输入学生姓名、年龄、性别"<<endl;
   cin>>name>>age>>sex;
   student.setName(name);
   student.setAge(age);
   student.setSex(sex);
   cout<<"学生信息为:"<<endl;
   cout<<student.getName()<<" "<<student.getAge()<<" "<<student.getSex()<<endl;





	system("pause");
	return 0;
}
本文参与?腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2014-11-16,如有侵权请联系 cloudcommunity@tencent.com 删除

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

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

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

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