How do I Overload these operators in this program?
I have a program in which you have to overload the operators (all under a class called ComplexNum) >>, <<, +, -, /, and *. My program is that I must take two sets of numbers, each set having two numbers, and manipulate each with these operators. But here is the kicker, one of the numbers is an imaginary number. Ok, here is an example:
---------------
Input file:
2.5 -2.2
1.0 1.0
Output (what it is suppose to be)
A = (2.5) + (-2.2)i
B = (1.0) + (1.0)i
A + B = (3.5) + (-1.2)i ....and so on
---------------
Ok, I have been given for example, what to do with the overloaded assignment operator, such as
>> extracts two parts of the complex number (or)
<< inserts the complex number with (a) + (b)i format (or)
+ is (a + c) + i(b+d)
* is (ac-bd) + i(bc + ad)
....so on
But how do I implent or do any of this? I was not instructed very well, and any help with the coding would be apreciated. Thanks,
aaron