Hello,
In my homework, I have to design a class Message; among other attributes, it has attribute "priority" (main goal is to implement priority queue).
As in container I must check if one object is greater than other, I have overloaded operator '>'. Now, I have a few general questions about it...
Question one:
If I overload operator '>', should I overload operator '<' for arguments (const Message&, const Message&)?
My opinion is that overloading both > and < and using it in code will generate an error:
if(message1 > message2)
{ ... }
(Does the following code calls operator > for message1 object, or operator < message2 object?)
But, what if I use operator like this:
if(message1 < message2)
{ ... }
? :confused:
operator> is declared as friend function:
friend bool operator>(const Message& m1, const Message& m2)
Does it need to be declared as member function?
Thank you.