C++语言程序设计中,有关运算符重载的相关规则与方法请参考:https://blog.csdn.net/PingBryant/article/details/123089725?spm=1001.2014.3001.5501
史上最全C++复数运算符重载代码如下:
#include<iostream>
using namespace std;
class Complex
{
public:
Complex(double x=0.0, double y=0.0); //构造函数
Complex(const Complex &c); //复制构造函数
~Complex(); //析构函数
Complex operator +(const Complex &c) const; //复数与复数相加
Complex operator -(const Complex &c) const; //复数与复数相减
//实数与复数相加,或者:Complex operator+(const double &number) const;
friend Complex operator +(const Complex &c, const double &number);
friend Complex operator +(const double &number, const Complex &