Hey, I would like to know the difference between these 2 operator definitions:
1:
class Rational{
//...
public:
//...
Rational operator -() const{ return Rational(-t,b);}
//...
};
2:
class Rational{
//...
public:
//...
friend Rational operator -(const Rational& v) {return Rational(-t,b);}
//...
};
as far as i understand, for the usage of:
Rational s = -r
r.operator-() // should happen
would like some explenation for the difference, thanks !