i tring to learn operator overloading and i dont get somthing. when i do:
class Point
{
public:
void show(){ cout << "the point is(" << _x << ", " << _y << ")" << endl;}
void print(){ _x = 1; _y = 1; }
void operator+=(const Point &other){
_x = other._x + 100;
_y = other._y + 100;
}
private:
int _x;
int _y;
};
int main()
{
Point p1;
Point p2;
p1 +=p2;
p2.show();
getchar();
}
its work. but when i change it to:
Point p1;
Point p1;
Point p2;
Point p3;
p1 +=p2 +=p3;
its doesnt and i need to return (*this). why is it? if someone can explain it to me i will be greatfull.. thanks :)