#include using namespace std; typedef const char * String; typedef unsigned short ushort; class Person{ public: String Name; Person(String name):Name(name){} }; class Student:public Person{ public: float CGPA; Student(String name, float cgpa):Person(name),CGPA(cgpa){ } //Student():Name(""),CGPA(0.0F){ Student():Student("",0.0F){ } }; class Staff:public Person{ public: double Salary; Staff(String name, double salary):Person(name),Salary(salary){ } virtual double getMonthlySalary()=0; //Pure Virtual Function (Abstract Method) const double EPF_CONTRIBUTION=0.11; }; class Lecturer:public Staff{ public: float Allowance; Lecturer(String name, double salary, float allowance): Staff(name,salary),Allowance(allowance){ } double getMonthlySalary(){//The operation return (1.0-EPF_CONTRIBUTION)*Salary + Allowance;//The Method! } }; class Clerk:public Staff{ public: ushort OTHours; float OTRate; Clerk(String name, double salary, float otRate): Staff(name,salary),OTRate(otRate){ OTHours = 0; } double getMonthlySalary(){//The operation return (1.0-EPF_CONTRIBUTION)*Salary + (OTHours * OTRate);//The Method! } }; class Manager:public Staff{ public: float CarAllowance; Manager(String name, double salary, float carAllowance): Staff(name,salary),CarAllowance(carAllowance){ } virtual double getMonthlySalary(){//The operation return (1.0-EPF_CONTRIBUTION)*Salary + CarAllowance;//The Method! } }; class HRManager:public Manager{ public: HRManager(String name, double salary):Manager(name,salary,500.0F){ } }; class SalesManager:public Manager{ public: float PetrolAllowance; double MonthlySales; SalesManager(String name, double salary, float carAllowance,float petrolAllowance): Manager(name,salary,carAllowance), PetrolAllowance(petrolAllowance),MonthlySales(0.0){ } double getMonthlySalary(){//The operation return (1.0-EPF_CONTRIBUTION)*(0.6*Salary) + CarAllowance + PetrolAllowance + (0.1*MonthlySales);//The Method! } }; void ShowManagerInfo(Manager *m){ cout<<"Monthly Salary:$"<getMonthlySalary()<<"\tName:"<Name<MonthlySales = 100000.0; ShowManagerInfo(sm); delete m; delete sm; delete hrm; return 0; }