第十一周项目2 职员有薪水了
2015-05-19 12:18
274 查看
/* *Copyright(c)2014,烟台大学计算机学院 *All rights reserved. *文件名称:test.cpp *作者:曾晓 *完成日期:2015年 5月 19日 *版本号:v1.0 */ #include <iostream> #include <cstring> #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(); }; 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(); }; 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<<"The information of these employees:"<<endl; cout<<"Name:"<<m_szName<<endl; cout<<"IDNumber:"<<m_szId<<endl; cout<<"Sex:"; if(m_nSex==0) cout<<"women"; else if(m_nSex==1) cout<<"men"; cout<<"Age:"<<m_nAge<<endl; } CPerson::~CPerson(){} 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<<"The information of these employees:"<<endl; cout<<"Name:"<<m_szName<<endl; cout<<"IDNumber:"<<m_szId<<endl; cout<<"Sex:"; if(m_nSex==0) cout<<"women"; else if(m_nSex==1) cout<<"men"; cout<<"Age:"<<m_nAge<<endl; cout<<"Department:"<<m_szDepartment<<endl; cout<<"Salary:"<<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; }
运行结果:
我现在有点慌怎么突然...
相关文章推荐
- 第十一周项目二职员有薪水了(1)
- 第十一周项目2--职员有薪水了(2)
- 第十一周上机项目2 职员有薪水了
- 第十一周 项目二 职员有薪水了(1)
- 第十一周项目二-职员有薪水了
- 第十一周项目2-职员有薪水了
- 第十一周【项目2 - 职员有薪水了】
- 第十一周项目2--职员有薪水了
- 第十一周(项目二 拓展)——职员有薪水了 (拓展)。
- 第十一周项目2 - 职员有薪水了
- 第十一周项目2 - 职员有薪水了(2、来个深复制)
- 第十一周 项目二 职员有薪水了
- 第十一周项目二--职员有薪水了(char*型)
- 第十一周【项目2 - 职员有薪水了】
- 第十一周项目2——职员有薪水了
- 第十一周项目二——职员有薪水了(2)
- 第十一周项目2 - 职员有薪水了
- 第十一周项目2 - 职员有薪水了
- 第十一周 项目二:(1) 职员有薪水了
- 2015年第十一周项目二:职员有薪水了(1)