← Back to Classes
Question 68
Complex Negation (unary operator-)
Complex Negation (unary operator-)
You are working with 2D rotations using complex numbers. Create a class Complex2 with two ints: real and imag. Requirements: 1) Constructor Complex2(int r, int i) 2) GettersgetR()const,getI()const 3) Overload UNARY operator- to return a NEW Complex2 with both parts negated Do NOT write a main function.
Expected Output:
-3 4 0 7
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
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.