Write a class definition for a complex number. The class definition should inclu
ID: 3613630 • Letter: W
Question
Write a class definition for a complex number.The class definition should include variables that represent thereal and imaginary part of the number.
You should include a constructor that allows you to specify thereal and imaginary parts and a default constructor.
You should also include functions that allow you to add, substract,multiply and divide two complex numbers. The functions return typeshould be complex number.
Also include a function called toString which displays the complexnumber.
THIS IS WHAT I GOT SO FAR PLEASE HELP !!!!!WILL RATELIFESAVER!!
#include <iostream>using namespace std;class ComplexNumber {public:ComplexNumber();ComplexNumber(double inputreal,double inputimaginary);ComplexNumber add(ComplexNumber input);ComplexNumber subtract(ComplexNumber input);ComplexNumber multiply(ComplexNumber input);ComplexNumber divide(ComplexNumber input);void toString();private:double real;double imaginary;}int main() {ComplexNumber number1 = ComplexNumber(1,2);ComplexNumber number2 = ComplexNumber(3,4);ComplexNumber sum = number1.add(number2);ComplexNumber difference = number1.subtract(number2);ComplexNumber product = number1.multiply(number2);ComplexNumber quotient = number1.divide(number2);sum.toString();difference.toString();product.toString();quotient.toString();return(0);} Write a class definition for a complex number.The class definition should include variables that represent thereal and imaginary part of the number.
You should include a constructor that allows you to specify thereal and imaginary parts and a default constructor.
You should also include functions that allow you to add, substract,multiply and divide two complex numbers. The functions return typeshould be complex number.
Also include a function called toString which displays the complexnumber.
THIS IS WHAT I GOT SO FAR PLEASE HELP !!!!!WILL RATELIFESAVER!!
#include <iostream>using namespace std;class ComplexNumber {public:ComplexNumber();ComplexNumber(double inputreal,double inputimaginary);ComplexNumber add(ComplexNumber input);ComplexNumber subtract(ComplexNumber input);ComplexNumber multiply(ComplexNumber input);ComplexNumber divide(ComplexNumber input);void toString();private:double real;double imaginary;}int main() {ComplexNumber number1 = ComplexNumber(1,2);ComplexNumber number2 = ComplexNumber(3,4);ComplexNumber sum = number1.add(number2);ComplexNumber difference = number1.subtract(number2);ComplexNumber product = number1.multiply(number2);ComplexNumber quotient = number1.divide(number2);sum.toString();difference.toString();product.toString();quotient.toString();return(0);}