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 with
Code:
//Here is the Overloading Problem
Here I am re describing it.
This is the Prototype
Code:
Point operator +=(int);//Overloading += Operator
This is the operator Function
Code:
Point Point::operator+=(int inc){
this->x += inc;
this->y += inc;
return *this;
}
And this is how I am using this
Code:
pt2+=5;//here is the problem
The Problem is the Output
Code:
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
It shouldn't Be 19 and 0
Whatever I Do with it Its always 19 and 0 Why ??
How can I solve it ??
I an using g++ on Linux