Question: Implement the +, -, *, / operator of the complex number class below: (15 Point) class Complex { // complex number class float re; //

  1. 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

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!