4.11. Assignment Operators
C++ provides several assignment operators for abbreviating assignment expressions. For example, the statement
c = c + 3;
c += 3;
The += operator adds the value of the expression on the right of the operator to the value of the variable on the left of the operator and stores the result in the variable on the left of the operator. Any statement of the form
in which the same variable appears on both sides of the assignment operator and operator is one of the binary operators +, -, *, /, or % (or others we'll discuss later in the text), can be written in the form
Thus the assignment c += 3 adds 3 to c. Figure 4.19 shows the arithmetic assignment operators, sample expressions using these operators and explanations.