class employee
{
protected:
int individualEmpNo; //个人编号
int grade; //级别
float accumPay; //月薪
public:
employee();
~employee();
void IncreaseEmpNo(int); //增加编号函数
void promote(int); //升级函数
void SetaccumPay(float); //设置月薪函数
int GetindividualEmpNo(); //提取编号函数
int Getgrade(); //提取级别函数
float GetaccumPay(); //提取月薪函数
};
employee::employee()
{
individualEmpNo=1000; //员工编号目前最大编号为1000
grade=1; //级别初值为1
accumPay=0.0; //月薪总额初值为0
}
employee::~employee() {}
void employee::IncreaseEmpNo(int steps)
{
individualEmpNo+=steps; //增加编号,增加的步长由steps指定
}
void employee::promote(int increment)
{
grade+=increment; //升级,提升的级数由increment指定
}
void employee::SetaccumPay(float pa)
{
accumPay=pa; //设置月薪
}
int employee::GetindividualEmpNo()
{
return individualEmpNo; //获取成员编号
}
int employee::Getgrade()
{
return grade; //获取级别
}
float employee::GetaccumPay()
{
return accumPay; //获取月薪
}
#include<iostream>
using namespace std;
int main()
{
employee m1;
employee t1;
employee sm1;
employee s1;
cout<<"请输入下一个雇员的月薪:";
float pa;
cin>>pa;
m1.IncreaseEmpNo(0);
m1.promote(3);
m1.SetaccumPay(pa);
cout<<"请输入下一个雇员的月薪:";
cin>>pa;
t1.IncreaseEmpNo(1);
t1.promote(2);
t1.SetaccumPay(pa);
cout<<"请输入下一个雇员的月薪:";
cin>>pa;
sm1.IncreaseEmpNo(2);
sm1.promote(2);
sm1.SetaccumPay(pa);
//显示m1信息
cout<<"编号"<<m1.GetindividualEmpNo()<<"级别为"<<m1.Getgrade()<<"级,本月工资"
<<m1.GetaccumPay()<<endl;
//显示m1信息
cout<<"编号"<<t1.GetindividualEmpNo()<<"级别为"<<t1.Getgrade()<<"级,本月工资"
<<t1.GetaccumPay()<<endl;
//显示sm1信息
cout<<"编号"<<sm1.GetindividualEmpNo()<<"级别为"<<sm1.Getgrade()<<"级,本月工资"
<<sm1.GetaccumPay()<<endl;
}