I'm having trouble overloading the comparison operators > and <. I've tried two different ways but I'm still having trouble.
bool Car::operator ==(const Car &car)
{
return mLNumber == car.GetNum();
}
bool Car::operator <(const Car &carB)
{
return mLNumber < carB.GetNum();
}
bool Car::operator >(const Car &carB)
{
return mLNumber > carB.GetNum();
}
int Car::GetNum()
{
return mLNumber;
}
My == operator works just fine. I get the error that these operators don't exist. Here is my 2nd attempt.
bool Car::operator <(const Car &carA, const Car &carB)
{
return carA.GetNum() < carB.GetNum();
}
bool Car::operator >(const Car &carB)
{
return carA.GetNum() > carB.GetNum();
}
And I get the error that there are too many parameters. I also get this:
'Car::GetNum' : cannot convert 'this' pointer from 'const Car' to 'Car &'