xHarbour Reference Documentation > Operator Reference |
Increment operator (unary): prefix / postfix increment.
++ <Variable> <Variable> ++
The increment operator increases the value of its operand by one. When used in an expression, the position of the operator is important for the result of the expression.
When the operator appears to the left of the operand (prefix notation), the operand's value is first incremented and then used in the expression.
When the operator appears to the right of the operand (postfix notation), the operand's value is first used in the expression and then incremented.
See also: | +, --, :=, = (compound assignment) |
Category: | Mathematical operators , Operators |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example demonstrates the use of the ++ operator and // outlines the importance of prefix and postfix notation. PROCEDURE Main LOCAL nValue1 := 0 LOCAL nValue2 ? nValue1 ++ // result: 0 ? nValue1 // result: 1 ? ++ nValue1 // result: 2 ? nValue1 // result: 2 nValue2 := ++ nValue1 ? nValue1 // result: 3 ? nvalue2 // result: 3 nValue2 := nValue1 ++ ? nValue1 // result: 4 ? nvalue2 // result: 3 RETURN
http://www.xHarbour.com