For my exam practice I am trying to overload ">" operator to check if left handside is bigger than right handside.
It needs to compare salaries from two different classes. But only PartTimeDoctor class has "salary" variable. FullTimeDoctor class has "baseSalary" variable which calculated differently from "salary".
The original question is,
Overload ‘greater than’ operator as a global function which gets two Doctor objects as parameters and returns true if the left hand side doctor object earns more than that of right hand side doctor.
Base class:
class Doctor {
protected:
string name, surname, expertise;
public:
Doctor();
void print();
void calcTotalPayment();
};
Inherited Class:
class FullTimeDoctor : public Doctor {
private:
int baseSalary;
int feeShift;
public:
void setBaseSalary(int);
int getBaseSalary();
void setFeeShift(int);
int getFeeShift();
FullTimeDoctor();
void print();
void calcTotalPayment();
};
Inherited Class
class PartTimeDoctor : public Doctor {
private:
int feePerEx;
int numOfEx;
int salary;
public:
PartTimeDoctor();
void setFeePerEx(int);
int getFeePerEx();
void setNumOfEx(int);
int getNumOfEx();
void calcTotalPayment();
void print();
};
I did not add cpp files here but they are all ok. So how can I do this overloading? Thanks in advance.