I have this code which I wish to switch from friend functions to member functions:
inline bool operator< (const MyClass& left, const MyClass& right)
{
return (((left.value == 1) ? 14 : left.value) < ((right.value == 1) ? 14 : right.value));
}
inline bool operator> (const MyClass& left, const MyClass& right)
{
// recycle <
return operator< (right, left);
}
I have got this far:
inline bool MyClass::operator< (const MyClass& right)
{
return (((this->value == 1) ? 14 : this->value) < ((right.value == 1) ? 14 : right.value));
}
inline bool MyClass::operator> (const MyClass& right)
{
// recycle <
return right.operator<(*this);
}
However, VC++ gives me this complain:
cannot convert 'this' pointer from 'const MyClass' to 'MyClass &'
How can I fix this? Beside, is my operator>
correctly written?