Question: Implement a class for arithmetic using imaginary numbers ( a + i b ) . The class has the following constructors and overloaded operators: *
Implement a class for arithmetic using imaginary numbers a i b The class has the following constructors and overloaded operators:
A constructor with no arguments sets the real and imaginary parts of the object to values
A constructor with two arguments a and b sets the real part to parameter a and the imaginary part to parameter b
Operator adds to imaginary numbers.
Operator subtracts two imaginary numbers.
Operator multiplies two imaginary numbers.
Operator displays an imaginary number.
Operator reads an imaginary number.
Operator assigns the rightside object to the left side object, eg a b
Operator returns true if two imaginary numbers are equal and falseotherwise
Operator returns true if two imaginary numbers are different and false otherwise.
The main program should demonstrate the use of all the above constructors and overloaded operators.
And fix the error of the code below.
#include
#include
#include
using namespace std;
class Imaginary
public:
Imaginary ;
Imaginary float a float b;
Imaginary& operatorImaginary &a;
operatorImaginary& v;
friend ostream& operatorostream& out, Imaginary& a;
private:
float real;
float imag;
;
Imaginary :: Imaginary
real ; imag ;
Imaginary :: Imaginary float a float b
real a; imag b;
Imaginary& Imaginary :: operatorImaginary& a
Imaginary v;
vreal real aimag;
vimag imag aimag;
return v;
Imaginary :: operatorImaginary& v
real vreal;
imag vimag;
ostream& operatorostream& out, Imaginary& a
out areal i aimag endl;
return out;
int main
class Imaginary in in in;
in in in;
cout in;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
