您的位置:首页 > 其它

第十一周项目2 - 职员有薪水了

2014-05-06 15:21 295 查看
/*烟台大学计算机学院学生
*All right reserved.
*文件名称*烟台大学计算机学院学生
*作者:初瑞
*完成日期:2014年5月6日
*版本号:v1.0
*对任务及求解方法的描述部分:项目2 - 职员有薪水了
*我的程序:*/
#include <iostream>
using namespace std;
class CPerson
{
protected:
string m_szName;
string m_szId;
int m_nSex;//0:women,1:man
int m_nAge;
public:
CPerson(string name,string id,int sex,int age):
m_szName(name),m_szId(id),m_nSex(sex),m_nAge(age){};
void Show1()
{
cout<<"姓名"<<m_szName<<endl;
cout<<"身份证号码"<<m_szId<<endl;
cout<<"性别"<<m_nSex<<endl;
cout<<"年龄"<<m_nAge<<endl;
}
~CPerson()
{

};
};
class CEmployee:public CPerson
{
private:
string m_szDepartment;
double m_Salary;
public:
CEmployee(string name,string id,int sex,int age,string department,double salary):CPerson(name,id,sex,age)
{
m_szDepartment= department;
m_Salary=salary;
};

void Show2()
{
Show1();
cout<<"部门"<<m_szDepartment<<endl;
cout<<"工资"<<m_Salary<<endl;
}
~CEmployee()
{

};
};
int main()
{
string name,id,department;
int sex,age;
double salary;
cout<<"input employee's name,id,sex(0:women,1:man),age,department,salary:\n";
cin>>name>>id>>sex>>age>>department>>salary;
CEmployee employee1(name,id,sex,age,department,salary);
employee1.Show2();
return 0;
}

运算结果:



心得体会:仿照项目一写出的项目二
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: