万圣节快乐….

View Code
 1 #include <iostream>
 2 using namespace std;
 3 
 4 class CEmployee{
 5     
 6     public:
 7     
 8     int NO;
 9     char Name[5];
10     int Rank;
11     int Salary;
12     int JB;
13     
14     void SetNO(){
15         
16         cout<<"请输入员工编号:"<<endl;
17         cin>>NO;
18     }
19     inline int GetNO(){
20         
21         cout<<"员工的编号是:"<<NO<<endl;
22     }
23     void SetName(){
24          
25         cout<<"请输入员工的姓名:"<<endl;
26         cin>>Name; 
27     }
28     inline char GetName(){
29         
30         cout<<"员工的姓名是:"<<Name<<endl;
31     }
32     void SetRank(){
33         
34         cout<<"请输入员工等级:"<<endl;
35         cin>>Rank;
36     }
37     inline int GetRank(){
38         
39         cout<<"员工的等级是:"<<Rank<<endl;
40     }
41     inline int GetSalary(){
42         
43         cout<<"员工的工资是:"<<JB*Rank<<endl;
44     } 
45 };
46 class CManager: public CEmployee{
47     
48     public :
49     
50     int JT;
51     
52     inline int GetSalary(){
53         
54        cout<<"员工的工资是:"<<JB*Rank+JT<<endl;
55     }                                                    //函数的重载 
56 };
57 int main(void){
58     
59     CEmployee a_Employee;               //实例化 CEmployee的对象 
60     a_Employee.JB = 1000; 
61     a_Employee.SetNO();
62     a_Employee.SetName();
63     a_Employee.SetRank();
64     a_Employee.GetNO();
65     a_Employee.GetName();
66     a_Employee.GetRank();
67     a_Employee.GetSalary();
68     
69     CManager a_Manager;                 //实例化 CManager的对象 
70     a_Manager.JT = 500;
71     a_Manager.JB = 1000; 
72     a_Manager.SetNO();
73     a_Manager.SetName();
74     a_Manager.SetRank();
75     a_Manager.GetNO();
76     a_Manager.GetName();
77     a_Manager.GetRank();
78     a_Manager.GetSalary();
79 
80 }

 

转载于:https://www.cnblogs.com/fengkuangbinbin/archive/2012/11/01/2750010.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值