Friday, February 20, 2009

Operator precedence

The following is a table that lists the precedence and associativity of all the operators in the C++ programming language. Operators are listed top to bottom in descending precedence and operators that are in the same cell (there may be several rows of operators listed in a cell) are evaluated with the same precedence, in the given direction.
The syntax of expressions in C and C++ is specified by a context-free grammar. The table given here has been inferred from the grammar.
A precedence table, while mostly adequate, cannot resolve a few details. In particular, note that the ternary operator allows any arbitrary expression as its middle operand, despite being listed as having higher precedence than the assignment and comma operators. Thus a ? b , c : d is interpreted as a ? (b, c) : d, and not as the meaningless (a ? b), (c : d). Also, note that the immediate, unparenthesized result of a C cast expression cannot be the operand of sizeof. Therefore, sizeof (int) * x is interpreted as (sizeof(int)) * x and not sizeof ((int) *x).


Operators

  1. Operators are represented by Symbols.
  2. Each operator has its predefine working
  3. Operator use operands to perform an operation.
  4. Operators are devided in following categorey
  • Ariethmatic
  • Relational
  • Logical