/*
* 程序的版权和版本声明部分
* Copyright (c)2014, 烟台大学计算机学院学生
* All rightsreserved.
* 文件名称: array.cpp
* 作 者: 刘江
* 完成日期:2013年5月11日
* 版本号: v1.0
* 输入描述:无
* 问题描述:*/
#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<<" "<<m_szId<<" ";
if(m_nSex==0)
cout<<"women";
else
cout<<"men";
cout<<" "<<m_nAge;
}
~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()
{
cout<<"name"<<" "<<"id"<<" "<<"sex"<<" "<<"age"<<" "<<"department"<<" "<<"salary"<<endl;
Show1();
cout<<m_szDepartment<<" "<<m_Salary;
}
~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;
}
运行结果![](https://img-blog.csdn.net/20140511211021500?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGl1amlhbmd5dA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
项目二-职员有薪水
最新推荐文章于 2016-05-16 12:23:18 发布