RAD Studio
ContentsIndex
PreviousUpNext
Plus And Minus Operators

Unary  

In these unary + - expressions

+ cast-expression
- cast-expression

the cast-expression operand must be of arithmetic type. 

Results 

  • cast-expression Value of the operand after any required integral promotions. 

  • cast-expression Negative of the value of the operand after any required integral promotions. 

Binary  

Syntax

add-expression + multiplicative-expression
add-expression - multiplicative-expression

Legal operand types for op1 + op2:

  • 1. Both op1 and op2 are of arithmetic type.
  • 2. op1 is of integral type, and op2 is of pointer to object type.
  • 3. op2 is of integral type, and op1 is of pointer to object type.
In case 1, the operands are subjected to the standard arithmetical conversions, and the result is the arithmetical sum of the operands. 

In cases 2 and 3, the rules of pointer arithmetic apply. 

Legal operand types for op1 - op2:

  • 1. Both op1 and op2 are of arithmetic type.
  • 2. Both op1 and op2 are pointers to compatible object types.
  • 3. op1 is of pointer to object type, and op2 is integral type.
In case 1, the operands are subjected to the standard arithmetic conversions, and the result is the arithmetic difference of the operands. 

In cases 2 and 3, the rules of pointer arithmetic apply.

Note: The unqualified type <type> is considered to be compatible with the qualified types const type, volatile type,and const volatile type.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!