Udostępnij za pośrednictwem


Compound Assignment

The compound assignment operators, shown in the table in Assignment Operators, are specified in the form e1 op= e2, where e1 is a modifiable l-value not of const type and e2 is one of the following:

  • An arithmetic type

  • A pointer, if op is + or –

The e1 op= e2 form behaves as e1 = e1 op e2, but e1 is evaluated only once.

Compound assignment to an enumerated type generates an error message. If the left operand is of a pointer type, the right operand must be of a pointer type or it must be a constant expression that evaluates to 0. If the left operand is of an integral type, the right operand must not be of a pointer type.

See Also

Reference

Expressions with Binary Operators