Thread: Compiler Error
View Single Post
Old 06-10-2004, 05:45 PM   #1 (permalink)
saiz66
Registered User
 
Join Date: May 2004
Posts: 11
saiz66 is on a distinguished road
Compiler Error

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
Code:
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.
saiz66 is offline   Reply With Quote