<span style= "font-family:arial, Helvetica, Sans-serif;" > #include <iostream></span>
Using namespace Std;class complex{public://constructor with default value complex (double real = 0, double image = 0): _real (Real), _image (image) {cout<< "complex (double real = 0, double image = 0)" <<ENDL; destructor ~complex () {cout<< "~complex ()" <<ENDL;} Copy constructor complex (const complex& D): _image (D._image), _real (d._real) {cout<< "complex (const complex& D ) "<<ENDL;} The assignment operator Overloads complex& operator= (const complex& D) {cout<< "operator= (const complex& D)" <<endl;if ( This! = &d) {this->_real = D._real;this->_image = D._image;} return *this;} Fetch address operator overload complex* operator& () {cout<< "operator& ()" <<endl;return this; The const-Modified fetch address operator Overloads Const complex* operator& () const{cout<< "operator& () const" <<endl;return this;} void display () {cout<< "real:" <<_real<< "--image:" <<_IMAGE<<ENDL<<ENDL;} Please implement the following operator overloads! complex& operator++ ()//front + +//Returns the current object itself {cout<< "operator++ ()" ≪<endl; _real++; _image++;return *this; Can immediately reflect the value of the front + +}complex operator++ (int)//Post ++{cout<< "operator++ (int)" <<endl; Complex C = *this; this->_real++; this->_image++; return c;} complex& operator--() {cout<< "operator--()" <<endl; _real--; _image--; return *this;} Complex operator--(int)//--{cout<< "operator--()" <<endl; Complex C = *this; this->_real--; this->_image--; return c;} Complex operator+ (const complex& c) {cout<< "operator+ (const complex& c)" <<endl; Return complex (_real+c._real,_image+c._image);} Complex operator-(const complex& c) {cout<< "operator-(const complex& c)" <<endl; Return complex (_real-c._real,_image-c._image);} complex& operator-= (const complex& c) {cout<< "operator-= (const complex& c)" <<endl; _real-= C._real; _image-= C._image; return *this;} complex& operator+= (const complex& c) {cout<< "operator+= (const complex& c)" <<endl; _real + = C._real; _image + = C._image; return *this;} Complex operator* (const complex& c) {cout<< "operator* (const complex& c)" <<endl; Return complex (_real*c._real-_image*c._image,c._image*_real+_image*c._real);} Complex operator/(const complex& c) {cout<< "operator/(const complex& c)" <<endl; Return complex (_real/c._real+_image*c._image)/(C,_real*c._real+c._image*c._image), (_image*c._real-_real*c._ Image)/(C,_real*c._real+c._image*c._image));} Private:double _real;double _image;};
C + + operator overloading