C++ Language/Expressions/ChainOfAssignment
Appearance
The "compound assignment" iVar += 2;
is an abbreviation for iVar = iVar + 2;
.
Programmers usually think about +=
only in terms of its effect (changing the value stored in iVar
's memory), but that expression does also evaluate to a value.
In fact, it evaluates to a "lvalue" which means that iVar+=2
is allowed to occur on the left-hand-side of some other assignment (although it would be weird to do so).
Additional information about lvalues (includes interactive examples)