Thread: Compiler Error
View Single Post
Old 06-10-2004, 05:59 PM   #2 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
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.
__________________
Valmont is offline   Reply With Quote