Uuhhm wait a minute...
How about you overloading
operator< OUTSIDE the Patient class? Do you see why?
Code:
#ifndef PATIENT_H
#define PATIENT_H
class Patient
{
public:
Patient(){};
~Patient(){};
friend bool operator<(const Patient &T, const Patient &P);
public:
void setPriority(int priority)
{ itsPriority = priority; };
int getPriority()
{ return itsPriority; };
void setTime(int time);
int getTime();
void setMisdiagnose(int misdiagnose);
int getMisdiagnose();
private:
int itsPatientNumber;
int itsPriority;
int itsTime;
int itsMisdiagnose;
};
bool operator <(const Patient &T, const Patient &P)
{
if (T.itsPriority < P.itsPriority)
return true;
else if (T.itsPriority > P.itsPriority)
return false;
else if (T.itsTime < P.itsTime)
return false;
else
return true;
}
#endif //PATIENT_H
Do you also understand what the
friend keyword means?
Also learn to place private(s) last in the class declaration. Details last
