CJCoding With Joseph
15free / daySign inCreate account

You want to add complex numbers and print them cleanly.

Create a class Complex2 with ints real and imag.

Requirements: 1) Constructor Complex2(int r, int i) 2) operator+ returns NEW Complex2 by adding parts 3) operator<< prints as: a+bi or a-bi (no spaces) Examples: 3+4i, 5-2i

Do NOT write a main function.

Expected output

3+4i
5-2i

= newline. The output ends with a newline, so print one after the last line.

Hints4 available
Topics
ClassesOperator Overloading
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.