In principle, you could rewrite counter = counter - 1
, using an
augmented assignment operator, as counter -= 1
. You are not likely to
see such expressions, however, because C++ offers a still more concise
shorthand for adding 1 to, or subtracting 1 from, a variable. To use the
shorthand, you drop the equal sign altogether, along with the 1, and prefix
the variable with the
increment operator, ++
, or the
decrement operator, --
. Thus, you replace
counter = counter - 1
by the following expression:
--counter
Similarly, ++counter
means increment the value of
counter
by 1.