关于运算符重载,不知何处问题,多谢指教
#include <iostream>using namespace std;
class Point{
private:
int x;
int y;
public:
Point operator+(Point a,Point b);
Point operator=(Point a,Point b);
Point(){this->x=0;this->y=0;}
Point(int a,int b):x(a),y(b){}
void display();
};
Point Point::operator+(Point a,Point b){
a.x+=b.x;
a.y+=b.y;
return a;
}
Point Point::operator=(Point a,Point b){
a.x=b.x;
a.y=b.y;
return a;
}
void Point::display(){
cout<<"("<<this->x<<","<<this->y<<")"<<endl;
}
int main(){
Point point1(1,2),point2(2,1);
Point point3=point1+point2;
point3.display();
return 0;
}error C2804: binary 'operator +' has too many parameters
error C2804: binary 'operator =' has too many parameters