对自定义种的list实现多态

对自定义类的list实现多态

#ifndef EMPLOYEE_H
#define EMPLOYEE_H

#include <string>
#include <iostream>
using namespace std;

const int AccumPayManager = 12000;
const int AccumPaySalesManager = 8000;
const double DeductRateSalesman = 0.05;
const double DeductRateSalesManager = 0.04;


class employee
{
public:
employee(): grade(4), individualEmpNo(++tempNumber), wagePromotion(0) {}
employee(string strName, int iGra, int Num = ++tempNumber):
name(strName), grade(iGra), individualEmpNo(Num), wagePromotion(0) {}

virtual double PAY() const{return 0;};

// To promote an employee
virtual void promote() {};
virtual string displayPosition() const {return "NONE";};
virtual void transData(ofstream &of) {}

friend ostream& operator<<(ostream &, const employee *);
friend ostream& operator<<(ostream &, const employee &);
friend void initData(list<employee> &em, int &, int &, int &, int&);
friend void outitData(list<employee> &em, int intMan, int intTec, int intSMan, int intSManger);
protected:
int grade, individualEmpNo; 
string name;
static int tempNumber;
// promotion of one's payment
double wagePromotion;
};

// grade == 1
class manager: virtual public employee
{
public:
manager(string strName = "Default Name", int payment = AccumPayManager):
employee(strName, 1), accumPay(payment) {}; 
virtual double PAY() const
{
return accumPay + wagePromotion;
}
virtual void promote()
{
wagePromotion += 0.05 * PAY();
}
virtual string displayPosition() const
{
return "Manager";
}
virtual void transData(ofstream &of)
{
of << name << ' ' <<  accumPay << ' ' << individualEmpNo << endl;
}
protected:
int accumPay;
};

// grade == 2
class technician: virtual public employee
{