Question: Exercise 4.2: Take your solution to Exercise 4.1 and change it stack that the two data members REAL and IMAG are now both private but

 Exercise 4.2: Take your solution to Exercise 4.1 and change it
stack that the two data members REAL and IMAG are now both

Exercise 4.2: Take your solution to Exercise 4.1 and change it stack that the two data members REAL and IMAG are now both private but leave al the methods as public. Now, since you cant access these valtes directly from the main function anymore you must provide a constructor function that enables an object of this class to be initialised when it is declared. You should also define a default constructor that initialises both values to be set equal to zero. You should also provide two new public member functions to : Reset the values of the real and imaginary values of the Complex number, using the following prototype: void setvalues (double x, double y) You will also need to provide a print function to output a complex number to the screen (c.g. 2+i). The function should have the following prototype: void print) Demonstrate your new constructors, and your two new methods in action in the main function. #include using namespace std; class Complex int real, img public: Complex(){ /default constructor to initialize complex number to 0+01 real - 0; img - 0; > complex(int , int 1) /parameterized constructor to initialize complex number. real -ring - 13 > //Display the complex number void Display (void) { cout-07****-*} //finds the Modulus of the complex number double Modulus (void) return sqrt(powing, 2) pow(real,2)); > //finds the conjugate of the complex number complex conjugate (void) { Complex res; res.real-real: res.img-hing: return res > //finds the argument of the complex number float Argument(void) { if (real 46 img>0) return 90; 11(real 0 ingo) return -90; return atan(img/real)*180/3.14; cin>> ); int main() { cout>r; cout

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!