#include <iostream>
using namespace std;
class A {
int x, y;
public:
A(int a, int b)
{
x = a;
y = b;
}
void out()
{
cout << "\nx=" << x << "\ny=" << y;
}
void operator++(int)
{
x = x++;
y = y++;
}
};
int main()
{
A ob(5, 20);
ob.out();
ob.operator++(2);
ob.out();
return 0;
}
When I use only X++ it works but when I use X=X++ it doesn't increment the values. I don't understand why does this happening.
it gives 2 errors as
operation on '((A*)this)->A::x' may be undefined [-Wsequence-point]
operation on '((A*)this)->A::y' may be undefined [-Wsequence-point]
In the output values are not changed
x=5
y=20
x=5
y=20