class MyInt {
int _x;
public:
explicit MyInt(int x = 0) :_x(x) {}
MyInt operator++(int) {
MyInt tmp(*this);
++_x;
return tmp;
}
};
int main()
{
MyInt a(3);
MyInt b = ((a++) = MyInt(50));
return 0;
}
Why is an rvalue (returned by a++) being assigned to? Is there any way to make it not compile other than changing return type of operator++ to const MyInt?