Question: #include int main() { const Complex a(1.2, 2.0); // create a complex number with real=1.2 imag=2.0 const Complex b(0.5, 0.0); // real = 0.5, imag

#include
int main() {
const Complex a(1.2, 2.0); // create a complex number with real=1.2 imag=2.0
const Complex b(0.5, 0.0); // real = 0.5, imag = 0.0
const Complex c = a + b; // overload operator + using a friend function
c.print(); // should print the following to cout: (1.5,2.0)
// (member syntax). Should look the same as method add where the name add
// is replaced by operator +
const Complex d = a.add(b); // this should be the same as the above except the name
d.print();
Complex e = -d; // implement unary - using a member operator. Since it has one parameter which is this should have ZERO PARAMETERS!!!
cout << e << ' ';
}

Please keep following and write c++ code:

1.

Do not edit the main() function in any way.

2.

Create a Complex class in the same .cc file as main() that allows the program to compile and function properly. Pay special attention to the included comments in main() that explain how to implement the Complex class.

3.

+ member - friend * friend << friend

Example Output:

(1.5,2.0)

(1.5,2.0)

(-1.5,-2.0)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!