Question: Implement the +, -, *, / operator of the complex number class below: (15 Point) class Complex { // complex number class float re; //
- Implement the +, -, *, / operator of the complex number class below: (15 Point)
class Complex { // complex number class
float re; // real part
float im; // imagination part
public:
Complex(float r=0.0, float i=0.0){re=r; im=i;} // constructor
Complex(const Complex& c){re=c.re; im=c.im;} // copy constructor
void operator =(const Complex& c){re=c.re; im=c.im;}// assignment
Complex operator -()const{return Complex(-re, -im);}// unary negation
Complex operator +(const Complex&) const; // addition operator
Complex operator -(const Complex&) const; // subtraction operator
Complex operator *(const Complex&) const; // multiplication operator
Complex operator /(const Complex&) const; // division operator
};
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
