Increment/decrement Operators

From RAD Studio
Jump to: navigation, search

Go Up to Postfix Expression Operators Index

Increment operator ( ++ )

Syntax

postfix-expression ++       (postincrement)
++ unary-expression         (preincrement)

The expression is called the operand. It must be of scalar type (arithmetic or pointer types) and must be a modifiable lvalue..

Postincrement operator

The value of the whole expression is the value of the postfix expression before the increment is applied.

After the postfix expression is evaluated, the operand is incremented by 1.

Preincrement operator

The operand is incremented by 1 before the expression is evaluated. The value of the whole expression is the incremented value of the operand.

The increment value is appropriate to the type of the operand.

Pointer types follow the rules for pointer arithmetic.

Decrement operator ( -- )

Syntax

postfix-expression --       (postdecrement)
-- unary-expression         (predecrement)

The decrement operator follows the same rules as the increment operator, except that the operand is decremented by 1 after or before the whole expression is evaluated.