[Solved] How is the following expression be executed?


This is not legal C++ code.

The statement

a++ = b;

is not legal. Intuitively, you can only place something on the left-hand side of an assignment expression if it represents an object, not a value. For example, we can’t write

x + y = z;

because x + y is a value, not an object. The same principle is at play in your code: the expression a++ is not something that can be written to, as it means “change a by adding one to it, then produce the value that a used to have.”

The comments on your question talk about the formal terms that are used to describe what I’m referring to here as “values” and “something can be written to.” These are formally called lvalues, rvalues, prvalues, etc., and it might be worth looking into these to learn more about what sorts of assignment statements are legal.

0

solved How is the following expression be executed?