Reference no: EM13708013
Question 1: Write the class definition for a class called complex.
Complex numbers have the form
realPart + imaginaryPart * i
where I is the square of (-1)
Use double variable to show the private data of the class. Provide a constructor that enables an object of this class to be initialized when it is declared.
The constructor should contain default values of 0 in case no initializers are provided.
Provide public member functions that perform the given tasks:
Part 1: setComplex function to set complex number to set the real part and imaginary part of the complex number
Part 2: displayComplex function to print complex number in the form (a, b), where a is the real part and b is the imaginary part.
Question 2: Prepare a C++ program to test your class by using the given main function.
int main ()
{
complex c1(1, 2), c2(3, 4), c3;
c1.display();
c2.display()
c3.display();
c3.setComplex(5, 6);
c3.display();
return 0;
}
Can you show me how to write a proper code for these questions and how to complete it. Thanks