Create a class called complex for performing arithmetic operations with complex numbers. Use floating point variables to represent the private data of the class. Provide a default constructor that initializes the object with default values to -1. Provide public member functions for each of the following: • Addition of two complex numbers: It returns the result obtained by adding the respective real parts and the imaginary parts of the two complex numbers. (Return the object) • Subtraction of two complex numbers: It returns the result obtained by subtracting the respective real parts and the imaginary parts of the two complex numbers. (Return the object) • display(complex object) – It displays the complex number in a+bi format. The output should be displayed as follows:- Sum of a1+b1 i & a2+b2 i is : a3+b3
Create a class called complex for performing arithmetic operations with complex numbers. Use floating point variables to represent the private data of the class. Provide a default constructor that initializes the object with default values to -1. Provide public member functions for each of the following:
• Addition of two complex numbers: It returns the result obtained by adding the respective real parts and the imaginary parts of the two complex numbers. (Return the object)
• Subtraction of two complex numbers: It returns the result obtained by subtracting the respective real parts and the imaginary parts of the two complex numbers. (Return the object)
• display(complex object) – It displays the complex number in a+bi format.
The output should be displayed as follows:-
Sum of a1+b1 i & a2+b2 i is : a3+b3

Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 4 images









