An assignment operator with signature Fraction operator=(const Fraction &newfraction)
has to be a member function. A friend
function is not a member. So the numbers of parameters don’t match the 2 needed for assignment. Remove the friend
and make sure it is declared as a member function.
struct Fraction
{
Fraction& operator=(const Fraction &newfraction) { .... }
....
};
Also note that traditionally the assignment operator returns a reference to *this
, not a value.
2
solved I want to overload “=” operator but it gives me error [closed]