#pragma once
classComplex{public:Complex();Complex(int real, int imag);~Complex();
Complex&Add(const Complex& other);
Complex operator+(const Complex& other);voidDisplay()const;private:
int real_;
int imag_;};
Complex.cpp
#include "Complex.h"
#include <iostream>
using namespace std;
Complex::Complex(){}
Complex::Complex(int real, int imag):real_(real),imag_(imag){}
Complex::~Complex(){}
Complex& Complex::Add(const Complex& other){
real_ += other.real_;
imag_ += other.imag_;return*this;}
Complex Complex::operator+(const Complex& other){
int r = real_ + other.real_;
int i = imag_ + other.imag_;returnComplex(r, i);}void Complex::Display()const{
cout << real_ <<"+"<< imag_ <<"i"<< endl;}