Question

Extend your class for complex numbers to include an operation to initialize a complex number. The operation takes the real and imaginary parts as arguments. Also include a initial value constructor, that calls the initialize operation to install the initial value (Note: A constructor or function of a class can call another function in the class without specifying the instance; the current instance will be used directly.).

Write a program that initializes two complex numbers, one at its declaration and the other in the code, and then computes and outputs their sum and product.

Answer