S
saiz66
I am having a compiler error when running my program. It opens
pqueuebh.cpp(this is a priority queue class my teacher already wrote)
and points to this line of the Insert code
if ( CurrentSize>1 && Element<Array[CurrentSize/2] )
error C2678: binary '<' : no operator defined which takes a
left-hand operand of type 'const class Patient' (or there is no
acceptable conversion)
I am passing my Patient object. What I understand from the error code
is that it has somethign to do with my < operator. But I already
overloaded it. Here is my Patient class with my overloaded operator
class Patient
{
private:
int itsPatientNumber;
int itsPriority;
int itsTime;
int itsMisdiagnose;
public:
Patient();
~Patient();
void setPriority(int priority);
int getPriority();
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;
}
};
Thanks.
pqueuebh.cpp(this is a priority queue class my teacher already wrote)
and points to this line of the Insert code
if ( CurrentSize>1 && Element<Array[CurrentSize/2] )
error C2678: binary '<' : no operator defined which takes a
left-hand operand of type 'const class Patient' (or there is no
acceptable conversion)
I am passing my Patient object. What I understand from the error code
is that it has somethign to do with my < operator. But I already
overloaded it. Here is my Patient class with my overloaded operator
class Patient
{
private:
int itsPatientNumber;
int itsPriority;
int itsTime;
int itsMisdiagnose;
public:
Patient();
~Patient();
void setPriority(int priority);
int getPriority();
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;
}
};
Thanks.