I am trying to overload the operator==
, but the compiler is throwing the following error:
‘bool Rationalnumber::operator==(Rationalnumber, Rationalnumber)’ must take exactly one argument
My short piece of code is as follows:
bool Rationalnumber::operator==(Rationalnumber l, Rationalnumber r) {
return l.numerator() * r.denominator() == l.denominator() * r.numerator();
}
Declaration:
bool operator==( Rationalnumber l, Rationalnumber r );
Does anyone have any ideas why it's throwing the error?