Question: IN C++ WITH COMMENTS: E1 define a new class called Complex. There should be two public data members, REAL and Imaginary, type float. Provide public

IN C++ WITH COMMENTS:

E1

define a new class called Complex.

There should be two public data members, REAL and Imaginary, type float.

Provide public member functions for each :

  • Getting the modulus of the Complex, use the following:

float Modulus(void)

  • Getting the angle of the Complex number, use the following:

float Argument(void)

  • Changing the complex number to be equal to its conjugate, use the following prototype:

void Conjugate(void)

request the user to put in values for a single Complex number and then print out all the information you can about the complex number using the methods listed above in the main function.

E2

change the previous solution it such that the two data members are both private but leave all the methods as public. Now, provide a constructor function that enables an object of this class to be initialised when it is declared. Define a default constructor that initialises both values to be set equal to zero. Provide two new public member functions to :

Reset the values of the real and imaginary values of the Complex number, using:

void setvalues(double x, double y)

Provide a print function to output a complex number to the screen. Use:

void print()

Show your new constructors, and your two new methods in action in the main function.

E3

Make two extra public member functions to overload the operators + and * to add and multiply two Complex numbers, respectively. Use prototype examples: Complex operator+(Complex)

Complex operator*(Complex)

Show your new operators in the main function.

E4

Create a new class called OneD Complex matrix. Class should contain two private data members, a pointer to type Complex and an integer N. Create a constructor with the following, OneD Complex matrix(int N). This constructor should take in a single paramater and use this to dynamically allocate memory for a 1D matrix of Complex numbers, then set all of the real values and imaginary values to be zero. Create a public method to set the values to random values and create a second public method to convert the matrix into its conjugate. The function examples should look like:

void set random values()

void conjugate()

Demonstrate objects of your new class in the main function. Then add a destructor to delete the allocated memory.

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!