您的位置:首页 > 其它

职员有薪水了

2016-05-27 19:21 197 查看
/*

*Copyright   (c)  2016,烟台大学计算机学院

*All rights reserved.

*文件名称:test.cpp

*作者: 武聪

*完成日期:2016年5月27日

*版本号:v1.0

*

*问题描述:

*输入描述:

*程序输出:

*/
#include<iostream>
#include <string>
#include <iomanip>
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);
void Show1();
~CPerson();
};

CPerson::CPerson(string name,string id,int sex,int age)
{
m_szName=name;
m_szId=id;
m_nSex=sex;
m_nAge=age;
}
void CPerson::Show1()
{
cout<<m_szName<<" "<<m_szId<<endl;
if((m_nSex)==0)
cout<<"women"<<endl;
else
cout<<"man"<<endl;
cout<<m_nAge<<endl;
}
CPerson::~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);
void Show2();
~CEmployee();
};
CEmployee::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 CEmployee::Show2()
{
cout<<"name  "<<"id  "<<"sex  "<<"age  "<<"department  "<<"salary  "<<endl;
cout<<m_szName<<" "<<m_szId;
if((m_nSex)==0)
cout<<"women ";
else
cout<<"man ";
cout<<m_nAge<<"  "<<m_szDepartment<<" "<<m_Salary<<endl;

}
CEmployee::~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;
}


运行结果:

<img src="https://img-blog.csdn.net/20160527192649211?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
知识点总结:
函数的使用
学习心得:
我会好好努力


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: