文档介绍:精品文档
精品文档
1
精品文档
浙江理工大学信息学院
实验指导书
实验名称:类的多态性的实现
学时安排:
3
精品文档
精品文档
11
精品文档
实验类别:设计性实验
实验要求:acestd;
classEmployee
精品文档
精品文档
7
精品文档
{
protected:
stringname;
stringID;
stringsex;
stringjob;
CDatedate;
doublebasicmoney;
public:
Employee(stringID,stringname,stringsex,CDatedate,stringjob,doublebasicmoney);
stringgetjob(){returnjob;}
stringgetname(){returnname;}
stringgetID(){returnID;}
stringgetsex(){returnsex;}
doublegetbasicmoney(){returnbasicmoney;}
CDategetdate(){returndate;}
virtualdoublegetpay(intm)=0;
};
classReport
{
private:
list<Employee*>members;
list<Employee*>operator[](stringjob);
doublemin_pay(list<Employee*>emp_list,intmonth);doublemax_pay(list<Employee*>emp_list,intmonth);voidprint(list<Employee*>emp_list,intmonth);
public:
~Report();
精品文档
精品文档
8
精品文档
voidinsert(Employee*p);
voidprint(intn);
};
classManager:publicEmployee
{
private:
map<int,int>price;
public:
精品文档
精品文档
9
精品文档
Manager(stringjob,double
ID,string
name,string
sex,CDatedate,stringbasicmoney,map<int,int>
精品文档
精品文档
11
精品文档
price):Employee(ID,name,sex,date,job,basicmoney)
{this->price=price;}
doublegetpay(intm);
};
classTechnicist:publicEmployee
{
public:
Technicist(stringID,stringname,stringsex,CDatedate,stringjob,doublebasicmoney):Employee(ID,name,sex,date,job,basicmoney){}
doublegetpay(intm);
};
classSalesPerson:publicEmployee
{
private:
map<int,int>sales;
public:
精品文档
精品文档
11
精品文档
SalesPerson(stringjob,double
ID,string
name,string
sex,CDatedate,stringbasicmoney,map<int,int>
精品文档
精品文档
11
精品文档
sales):Employee(ID,name,sex,date,job,basicmoney)
精品文档
精品文档
11
精品文档
{this->sales=sales;}doublegetpay(intm);
};
#endif
//
#include""
#include<iostream>
#include<algorithm>
usingnamespacestd;
Employee::Employee(stringID,stringname,stringsex,CDatedate,string
job,doublebasicmoney)
{
this->ID=ID;
this->name=name;
this->sex=sex;
this->date=date;
this->basicmoney=basicmoney;
this->j