Hi,
I'm not sure if
return *this
is the only way we could return an instance of a class who called a member function? Reason why I asked is because our instructor told us to avoid using pointers if necessary and I'm wondering if this is a case where the only necessary way to do it is by returning the this pointer.
I'm working with a fraction class that holds private data members numerator and denominator. The member function I'm talking about is used to add two fractions for example:
Fraction C = A.plus(B);
plus member function is defined as this:
Fraction& plus( const Fraction frac )
EDIT:
The instructor wants us to do C = A += B .. so I guess that's why..
Thanks for the clear and helpful answers BTW