I am facing Problem while overloading the += Operator
I've posted My Code here http://phpfi.com/245888 So that you can read it easily. The problems are Commented Out there withHere I am re describing it.Code://Here is the Overloading Problem
This is the Prototype
This is the operator FunctionCode:Point operator +=(int);//Overloading += Operator
And this is how I am using thisCode:Point Point::operator+=(int inc){
this->x += inc;
this->y += inc;
return *this;
}
The Problem is the OutputCode:pt2+=5;//here is the problem
It shouldn't Be 19 and 0Code:Describing Class : pt1 x = 15 y = 10
Describing Class : pt2 before Copying x = 4 y = 8
Describing Class : pt2 after Copying x = 15 y = 10
Describing Class : pt2 after Increment x = 19 y = 0
Whatever I Do with it Its always 19 and 0 Why ??
How can I solve it ??
I an using g++ on Linux