我是名大一新手,请问哪位人才能帮我修改下使这个人员类变的更高大上的样子~~
我是名大一新手,请问哪位人才能帮我修改下使这个人员类变的更高大上的样子~~本人不才, 期末设计只能写成这样,哪位帮我修饰一下
#include <iostream>
using namespace std;
/* 定义基类员工类Temployee */
class Temployee //基类声明
{
protected: //保护成员
int ID; //编号
char *Name; //姓名
public: //公有函数成员
void regist(int id, char *name);
void display( ); //显示员工信息
};
void Temployee :: regist(int id, char *name)
{
ID = id;
Name = name;
}
void Temployee :: display()
{
cout << " 编号 " << " 姓 名 " << endl;
cout << ID << " " << Name << endl;
}
/* 定义派生经理类Tmanager */
class Tmanager : protected Temployee
{
private:
float Accum; //固定月薪
char *Grade; //职务
public:
void set_pay(int id, char *name, char *grade, float monthpay);
void display(); //显示员工信息
};
void Tmanager :: set_pay(int id, char *name, char *grade, float monthpay)
{
regist(id, name);
Grade = grade;
Accum = monthpay;
}
void Tmanager :: display()
{
cout << " 编号 " << " 姓 名 " << " 职务 " << " 工资 " << endl;
cout << ID << " " << Name << " " << Grade << " " << Accum << endl;
}
/* 定义派生销售人员类Tsale */
class Tsale : protected Temployee
{
private:
char *Grade; //职务
double commrate; //按销售额提取报酬百分比
double sales; //当月销售额
float Accum; //计算工资
public:
void set_pay(int id, char *name, char *grade, double commrate, double sales);
void display(); //显示员工信息
};
void Tsale :: set_pay(int id, char *name, char *grade,
double commrate, double sales)
{
regist(id, name);
Grade = grade;
this->commrate = commrate;
this->sales = sales;
Accum = commrate * sales;
}
void Tsale :: display()
{
cout << " 编号 " << " 姓 名 " << " 职务 " << " 销售提成 "
<< " 销售额 " << " 工资 " << endl;
cout << ID << " " << Name << " " << Grade << " " << commrate
<< " " << sales << " " << Accum << endl;
}
int main()
{
Temployee epy1;
Temployee epy2;
epy1.regist(1001, "张大山");
epy2.regist(1002, "李明全");
epy1.display();
epy2.display();
Tmanager mana1;
mana1.set_pay(1001, "张大山", "经理", 8000);
mana1.display();
Tsale sale1;
sale1.set_pay(1002, "李明全", "销售员", 0.20, 30000);
sale1.display();
}
[ 本帖最后由 小林阿三 于 2014-6-24 21:46 编辑 ]