Question: 1) ComplexNumber.h - https://www.dropbox.com/s/z2usa3xud214lwm/ComplexNumber.h?dl=0 2) Hw4Main.cpp - https://www.dropbox.com/s/pzml3a1mcq0pvwx/Hw4Main.cpp?dl=0 3) Mandelbrot.cpp - https://www.dropbox.com/s/pku0qq3upivi030/Mandelbrot.cpp?dl=0 4) Mandelbrot.h - https://www.dropbox.com/s/kq70xkljrw1tpnk/Mandelbrot.h?dl=0 Classes: Operator Overloading Instructions Read Carefully - Using your

1) ComplexNumber.h - https://www.dropbox.com/s/z2usa3xud214lwm/ComplexNumber.h?dl=0 2) Hw4Main.cpp - https://www.dropbox.com/s/pzml3a1mcq0pvwx/Hw4Main.cpp?dl=0 3) Mandelbrot.cpp - https://www.dropbox.com/s/pku0qq3upivi030/Mandelbrot.cpp?dl=0 4) Mandelbrot.h - https://www.dropbox.com/s/kq70xkljrw1tpnk/Mandelbrot.h?dl=0

Classes: Operator Overloading

Instructions Read Carefully - Using your knowledge of classes by using operator overloading to enable calculations with complex numbers. You will then apply use this class to create a class that can output the Mandelbrot Set.

Question/Problem:

Implement the operators necessary to provide a viable ComplexNumber class for use in generating the Mandelbrot set. This will include overloads for the mathematical operations that are different for complex numbers. Specifically, the addition operation requires adding the real and imaginary parts separately. The multiplication operation requires handing both the real and imaginary parts of the multiplicands to produce the result.

Requirements: (Files provided in dropbox) implement the functions as declared in the header file ComplexNumber.h in a new file ComplexNumber.cpp and submit only this new file. The implementation should include:

ComplexNumber();

The default constructor that sets the real and imaginary parts to zero.

ComplexNumber(double real, double imaginary);

The constructor which takes two double values and sets the real and imaginary parts.

ComplexNumber& operator=(const ComplexNumber& rhs);

The assignment operator that takes a reference to a complex number from the right side of the equals and sets this object to those values.

double Magnitude();

A function that returns the magnitude of the complex number calculated using the Pythagorean Theorem, i.e. as the square root of the sum of the squares for the real and imaginary parts.

void SetReal(double realValue);

A mutator function that sets the real-value part of the complex number.

void SetImaginary(double imaginaryValue);

A mutator function that sets the imaginary-value part of the complex number.

friend ComplexNumber operator+(const ComplexNumber& lhs, const ComplexNumber& rhs);

A friend function that overloads and performs the addition operation for complex numbers, that is, it computes the sum of the real parts and the imaginary parts and returns the resulting complex number.

friend ComplexNumber operator*(const ComplexNumber& lhs, const ComplexNumber& rhs);

A friend function that overloads and performs the multiplication operation for complex numbers, that is: it computes the product of the real parts minus the product of the imaginary parts as the resulting real part and the sum of the products of the real and imaginary parts of the two multiplicands as the resulting imaginary parts. It should then return the resulting complex number.

friend ostream& operator

A function that overloads the stream insertion operator for printing. Complex numbers are generally printed in the form x + yi where x is the real part and y is the imaginary part.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Expected Output:

1) ComplexNumber.h - https://www.dropbox.com/s/z2usa3xud214lwm/ComplexNumber.h?dl=0 2) Hw4Main.cpp - https://www.dropbox.com/s/pzml3a1mcq0pvwx/Hw4Main.cpp?dl=0 3) Mandelbrot.cpp - https://www.dropbox.com/s/pku0qq3upivi030/Mandelbrot.cpp?dl=0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!