C++第11周(春)项目2 - 职员有薪水了
来源:互联网 发布:怎样学好单片机 编辑:程序博客网 时间:2024/06/06 02:16
/** 程序的版权和版本声明部分* Copyright (c)2014, 在校学生* All rightsreserved.* 文件名称: 1.cpp* 作 者: 刘旺* 完成日期:2014年5月9日* 版本号: v1.0* 输入描述:无* 问题描述: 定义一个名为CPerson的类,有以下私有成员:姓名、身份证号、性别和年龄,成员函数 :构造函数、析构函数、输出信息的函数。并在此基础上派生出CEmployee类, 派生类CEmployee增加了两个新的数据成员,分别用于表示部门和薪水。 要求派生类CEmployee的构造函数显示调用基类CPerson的构造函数, 并为派生类CEmployee定义析构函数,定义输出信息的函数*/#include <iostream>using namespace std ;class Cperson{ protected : string m_szName ;//姓名 string m_size ;// 身份证号 int n_Sex ; //性别 int m_nAge ; //年龄 public : Cperson(string m_sz , string m_si , int n , int m) ; //构造函数 void show() ; //输出成员 ~Cperson() ; //析构函数};Cperson::Cperson(string m_sz , string m_si , int n , int m):m_szName(m_sz),m_size(m_si),n_Sex(n),m_nAge(m){}void Cperson::show(){ cout << m_szName << " " << m_size << " " ; if(n_Sex==0){cout << "women" ;} else{cout << "man" ;} cout << " " << m_nAge << " " ;}Cperson::~Cperson(){}class Cemployee:public Cperson{ private : string m_szDeparment ; //部门 double m_Salary ; //薪水 public: Cemployee(string m_sz , string m_si , int n , int m, string m_d , double m_Sa) ; void Show2() ; ~Cemployee() ;};Cemployee::Cemployee(string m_sz , string m_si , int n , int m, string m_d , double m_Sa):Cperson(m_sz , m_si ,n,m){ m_szDeparment = m_d ; m_Salary = m_Sa ;}void Cemployee::Show2(){ show() ; cout << " " << m_szDeparment << " " << 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,deparment ,salary:\n" ; cin >> name >> id >> sex >> age >> department >> salary ; Cemployee employee(name , id , sex , age , department , salary ) ; cout << "姓名 身份证 性别 年龄 部门 薪水" << endl ; employee.Show2() ; return 0 ;}
实力是不断训练出来的。
0 0
- 第11周 【项目2 - 职员有薪水了】(2)
- 第11周项目2 - 职员有薪水了(2)
- 第11周 项目2 职员有薪水了
- 第11周 【项目2 - 职员有薪水了】(1)
- 第11周项目2职员有薪水了
- 第11周项目2 - 职员有薪水了(1)
- 第11周项目2-职员有薪水了
- C++第11周(春)项目2 - 职员有薪水了
- C++第11周(春)项目2 - 职员有薪水了
- 第11周项目3-职员有薪水了
- 第10-11周项目:职员有薪水了啦
- 第10周-项目2-职员有薪水了-string
- 第10周-项目2-职员有薪水了-char *
- 第10周项目2-1职员有薪水了
- 2015-第10周项目2-职员有薪水了
- 第11周 职员有薪水了
- 11【项目2 - 职员有薪水了】
- 项目2-职员有薪水了(1)(第10,11周补充项目)
- 位域[flags]
- ICA学习乐园
- 数据结构的学习笔记
- Matlab中pwelch的用法总结
- Linux时间编程
- C++第11周(春)项目2 - 职员有薪水了
- 在SEO网站优化过程中大家最容易犯的哪些错误
- 排序算法 两路合并排序
- sdut 2624 Contest Print Server (第四届省赛)
- Android属性之build.prop,及propeetrty_get/property_s
- 任务管理器中arcsom.exe和arcsoc.exe的个数问题
- URI,URL,URN http://www.360doc.com/content/07/0423/17/25308_462859.shtml
- hdu You can Solve a Geometry Problem too(判断两条线段相交)
- 一个杭州人的美国求医经历