December 2nd, 2008, 11:33 PM
Operator Overloading Question
Im new to this site but it seemed like a good place for programming questions.
This is the assignment I am working on:
Design, implement, and test a class “Complex” which uses the followings overloaded operators for complex number: >>, <<, +, –, *, and /.
The complex number is described as having a real component or real part a and an imaginary component or imaginary part b where i2 = -1: A = a + bi
Given the two complex numbers A and B then the following definition will help to overload the operators. For any pair of complex numbers apply all overloaded operators.
A = a + bi
B = c + di
>> It extracts two part of complex number.
<< It inserts the complex number with (a) + (b) i format.
+ A+B = (a + c) + (b + d)i
- A - B = (a - c) + (b - d)i
* A* B = (ac - bd) + (bc + ad)i
/ A / B = (ac + bd)/(c2 + d2)+ (bc -ad)/(c2 + d2)i
Plan 3P-I/O & Note (only for files) and test data for client program.
A = (2.5) + (-2.2) i
B = (1.0) + (1.0) i
A + B = (3.5) + ( -1.2) i
A - B = .. . .
A * B = .. . .
A / B = .. . .
I just dont really understand the whole operator overloading thing and was wondering if anyone had any pointers to completing this assignment.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.