We have a class (assuming there are some operations in functions, but constructor is default):
class X
{
public:
X& operator=(const X& rhs){}
const X& operator+(const X& rhs) const {}
const X& operator+(int m) {}
};
X a, b, c;
Q1: Why is a = a + 5 + c;
allowed and a = b + c + 5;
is not? We have:
Error C2679 binary '+': no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion).
Q2: Why (c = a + a) = b + c;
begins with b+c operation and not with a+a? (I found that out while debugging).
P.S. It's theoretical question only.