职员有薪水了
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="" />
知识点总结: 函数的使用
学习心得:
我会好好努力
相关文章推荐
- Apache服务器配置
- ajax返回200 ok但一直进入error而不是success
- php+linux的crontab实现定时抓取csdn文章到mysql数据库
- 0525《构建之法》8、9、10章读后感
- IBatis一对多查询
- 二叉树--红黑树
- git学习参考网站
- C#—实验9.1、9.2、9.3和9.4
- iOS:在objective-c 使用可变参数
- 泛型
- Android动画-Property Animation(一)
- 数据结构——栈
- Maven 常用命令
- 函数模板和模板函数
- 深入理解递归函数的调用过程
- Ajax教程—用户名是否被注册之案例篇(三)
- Makefile经典教程
- bzoj 3112: [Zjoi2013]防守战线 单纯形
- webservice 客户端 调用服务端 进行测试
- ACM程序设计选修课——Problem E:(ds:图)公路村村通(Prim)