Anda di halaman 1dari 1

C/C++ Operator Precedence

Precedence
1 2

Operators
:: ++ -() [] . -> typeid() const_cast dynamic_cast reinterpret_cast static_cast ++ -+ ! ~ (type) * & sizeof new, new[] delete, delete[] .* ->* * / % + << >> < <= > >= == != & ^ | && || ?: = += -= *= /= %= <<= >>= &= ^= |= throw ,

Description
Scope resolution (C++ only) Suffix increment Suffix decrement Function call Array subscript Element selection Element selection by pointer Runtime type information (C++ only) Type cast (C++ only) " " " Prefix increment Prefix decrement Unary plus Unary minus Logical NOT Bitwise NOT Type cast Indirection (pointer dereference) Address-of Size-of Dynamic memory allocation (C++ only) Dynamic memory deallocation (C++ only) Pointer to member (C++ only) Pointer to dereferenced member (C++ only) Multiplication Division Integer modulus (remainder) Addition Subtraction Bitwise shift left Bitwise shift right Less than Less than or equal to Greater than Greater than or equal to Equal to Not equal to Bitwise AND Bitwise XOR (exclusive or) Bitwise OR (inclusive or) Logical AND Logical OR Ternary conditional Assignment Assignment by sum Assignment by difference Assignment by product Assignment by quotient Assignment by remainder Assignment by bitwise left shift Assignment by bitwise right shift Assignment by bitwise AND Assignment by bitwise XOR Assignment by bitwise OR Throw an exception Sequence

Associativity
! Left to right ! Left to right

! Right to left

4 5 6 7 8

! Left to right ! Left to right ! Left to right ! Left to right ! Left to right

9 10 11 12 13 14 15 16

! Left to right ! Left to right ! Left to right ! Left to right ! Left to right ! Left to right ! Right to left ! Right to left

17 18

! Right to left ! Left to right

bw.org/contact