Overloading the '+' Operator

We will overload the + operator such that it will add two Complex objects and return the result as a Complex object. As we have learned in the lectures on overloading C++ operators, the operator function for + can either be a member function or a non-member function. The lecture notes discuss in detail which approach is better under what circumstances. For the purpose of this lab, we will implement this operator function as a member function

The operator + is a binary operator (meaning it takes two operands). The prototype of the operator function for overloading the + operator when implemented as member function is:

const Complex operator+ (const Complex& rhs) const;

The operator+ function is implemented in the following manner: