Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

C++ Language/Expressions/ChainOfAssignment

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

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)