I dont see where you passed your Patient code. Show it. Now I can only guess and I don't have time to make guesses. Perhpaps other collegues do have. Step in I'd say.
And think twice about your overloaded operator.
Basically it means: somePatient < otherPatient.
What does that mean actually? I should "intuitivly feel" what it means without looking at your implementation. Do you see what I mean?
Why not just test directly like:
Code:
somePatient.getPriority()< otherPatient.getPriority();
Anyway, there is nothting wrong with your class technically:
Code:
#include <iostream>
using namespace std;
class Patient
{
private:
int itsPatientNumber;
int itsPriority;
int itsTime;
int itsMisdiagnose;
public:
Patient(){};
~Patient(){};
public:
void setPriority(int priority)
{ itsPriority = priority; };
int getPriority()
{ return itsPriority; };
void setTime(int time);
int getTime();
void setMisdiagnose(int misdiagnose);
int getMisdiagnose();
bool operator <(const Patient &P)
{
if (itsPriority < P.itsPriority)
return true;
else if (itsPriority > P.itsPriority)
return false;
else if (itsTime < P.itsTime)
return false;
else
return true;
}
};
int main()
{
Patient pete, mary;
pete.setPriority(2);
mary.setPriority(3);
if(mary<pete)
cout<<"mary first!"<<endl;
else
cout<<"pete first!"<<endl;
return 0;
}
So you need to provide more info.