Operator Overloading
// . . . (same as on previous slide)
// We’re giving these member functions strange names, but
// the reason will soon be clear...
complex operator+(complex c);
complex complex::operator+(complex c)
float new_real = real_p + c.real_p; // We’re adding our value
float new_imag = imag_p + c.imag_p; // to the value of what
complex result(new_real, new_imag); // was passed to us.
// OR: return complex(new_real, new_imag)
What if we wanted a member function that would add?