Question: LANGUAGE: C++ Write a class for a complex number ADT . To refresh your memory, complex numbers have the form: a + b i .
LANGUAGE: C++
Write a class for a complex number ADT. To refresh your memory, complex numbers have the form: a+ bi. Where ais the real part, bis the imaginary part, and i represents the square root of -1(which doesn't exist and is therefore imaginary).
Standard mathematical operations are defined on complex numbers:
a+bi + c+di = (a+c) + (b+d)i a+bi - c+di = (a-c) + (b-d)i a+bi * c+di = (a*c-b*d) + (a*d+b*c)i // i*i == -1 (a*c+b*d) - (a*d-b*c)i a+bi / c+di = ---------------------- c*c + d*d -(a+bi) = (-a) + (-b)i
That last one is negation (aka opposite), of course.
And special operations are also defined:
___________ |a+bi| = \/ a*a + b*b // magnitude ____ a+bi = a-bi // conjugate
(For the curious:
2 ____ |a+bi| = a+bi * a+bi ____ a+bi a+bi * c+di ------ = ------------- c+di 2 |c+di|
If you really wanted to know...)
Define these operations (along with constructors, input/output, and accessors/mutators) for your ADT/class. Place your ADT in a library.
Write a driver to test the ADT behaviors thoroughly.
Properly apply inline'ing and const-ness to ALL of your class methods. (This includes proper use of initializer lists on constructors!)
(Optional) Overload the math operation methods to allow mixing Complexnumbers with built-in floating pointtypes.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
