Question: C++ Part 2. Given the following Complex Number class, Add three more overloaded operators: -,* and /. Test. /* C++ program to demonstrate the overloading

C++

Part 2.

Given the following Complex Number class,

Add three more overloaded operators: -,* and /.

Test.

/* C++ program to demonstrate the overloading of binary operator by subtracting one complex number from another. */

#include using namespace std; class Complex { private: float real; float imag; public: Complex(): real(0), imag(0){ } void input() { cout<<"Enter real and imaginary parts respectively: "; cin>>real; cin>>imag; } Complex operator - (Complex c2) /* Operator Function */ { Complex temp; temp.real=real-c2.real; temp.imag=imag-c2.imag; return temp; } void output() { if(imag<0) cout<<"Output Complex number: "<

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!