Write C++ code of class Complex that would represent a complex number. A complex number consists of a real part and an imaginary part and usually displayed in the form + ἰ (a is real part while b is imaginary). This class should consists of void show( ) to display the complex number in the form a + bi ( if imaginary part is positive) or a – bi ( if imaginary part is negative), void input( ) to assign values to the object of the Complex class. This Complex class should have two constructors i.e. default and parameterized. The object instantiated using default constructor should call input() to assign value to the real and imaginary part of the object. Also write code to overload + operator to add two complex numbers (objects). Comment your program properly and mention mutator and accessor as well. All functions should be inline except the constructors. Use this pointer wherever class data members are referred.
Write C++ code of class Complex that would represent a complex number. A complex number consists of a real part and an imaginary part and usually displayed in the form + ἰ (a is real part while b is imaginary). This class should consists of void show( ) to display the complex number in the form a
+ bi ( if imaginary part is positive) or a – bi ( if imaginary part is negative), void input( ) to assign values to the object of the Complex class. This Complex class should have two constructors i.e. default and parameterized. The object instantiated using default constructor should call input() to assign value to the real and imaginary part of the object. Also write code to overload + operator to add two complex numbers (objects). Comment your program properly and mention mutator and accessor as well. All functions should be inline except the constructors. Use this pointer wherever class data members are referred.
Step by step
Solved in 2 steps with 2 images