I try to overide — operator.
I want prefix and postfix — operator
but c# doesnot allowed it even that there is different signature’s function.
the code:
public static Rational operator --(Rational a)
{
a.Mona -= a.Mechane;
return a.reduce();
}
public static Rational operator --(Rational a, int _)
{
_ = 0;
Rational original = new Rational(a.Mona, a.Mechane);
a.Mona -= a.Mechane;
a.reduce();
return original;
}
the error:
Overloadable binary operator expected
I tried to do two operators
New contributor
SHACHA is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.