来看下 是重载的问题
#include<iostream>
class complex{
double i;
double j;
public:
complex():i(0),j(0){}
complex(double t,double k):i(t),j(k){}
double geti(){return i;}
double getj(){return j;}
complex& operator+=(complex a){i+=a.geti(),j+=a.getj(),return *this}
};
void main()
{
using namespace std;
complex a(1,1);
complex b(2,2);
complex c;
c+=b;
cout<<c.geti()<<"-----"<<c.getj()<<endl;
}
过不了是C:\Documents and Settings\Administrator\we.cpp(10) : error C2059: syntax error : 'return'怎么回事啊?