1.实际上是函数重载
2.可以重载为成员函数,也可以重载为普通函数
3.把含运算符的表达式转换成运算符函数的调用,操作数转换成函数参数
class Complex { public: double real,imag; Complex(double r=0,double i=0.0):real(r),imag(i){ } Complex operator-(const Complex &c); }; Complex operator+(const Complex &a,const Complex &b) { return Complex(a.real+b.real,a.imag+b.imag); } Complex Complex::operator-(const Complex &c) { return Complex(this->real-c.real,this->imag-c.imag); }