Question: Define a class for complex numbers, name it myComplex. In addition to the member functions that sets and gets the member attributes, define following member

Define a class for complex numbers, name it myComplex. In addition to the member functions that sets and gets the member attributes, define following member functions:

1. Constructors a. A constructor uses default parameters. b. Copy constructor

2. Mutators: setReal(), setImaginary()

3. Assessors: getReal(), getImaginary()

4. Overload output operators (<<) for myComplex class.

5. Overload input operator (>>) for myComplex class.

6. Overload assignment operator (=) for myComplex class

Write a driver program using myComplex class. Every member functions and operators should be called or activated to verify that they are working properly.

A complex number: A complex number has the form of a + bi, where a and b are real numbers and i is the square root of 1. We refer to a as the real part and b as the imaginary part of the complex number. For example: 2.5 + 3 i is a complex number. 2.5 is the real part and 3 is the imaginary part of 2.5 + 3 i

Member attributes: The class should have two member attributes to represent the real and imaginary parts of a complex number

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!