运算符重载
作用:用于自定义运算
形式:如:
1 类名 operator+( 类名 形参名, 类名 形参名 ){}
2 类名 operator+( 类名 形参名 ){}
代码实现1
#include<iostream>
using namespace std;
class complex{
friend complex operator+( const complex &A, const complex &B );
private:
int real, imag;
public:
complex( const int &r = 0, const int &i = 0 ):real(r),