运算符重载的问题
#include<iostream>using namespace std;
class complex
{
private:
double x,y;
public:
complex(double a=0,double b=0)
:x(a),y(b)
{}
friend ostream& operator <<(ostream& os,const complex& rhs);
};
ostream& operator <<(ostream& os,const complex& rhs)
{
os<<rhs.x<<" "<<rhs.y<<endl;
return os;
}
int main()
{
complex p(1,2);
cout<<p<<endl;
}