0% found this document useful (0 votes)
215 views1 page

Operator Precedence

The document describes the precedence of C/C++ operators. It lists operators from highest to lowest precedence and whether their associativity is left to right or right to left. The highest precedence operators are :: and ++/--, followed by (), [], ->, and then unary operators. The lowest precedence operators are assignment operators and ?, which have right to left associativity.

Uploaded by

adidas
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
215 views1 page

Operator Precedence

The document describes the precedence of C/C++ operators. It lists operators from highest to lowest precedence and whether their associativity is left to right or right to left. The highest precedence operators are :: and ++/--, followed by (), [], ->, and then unary operators. The lowest precedence operators are assignment operators and ?, which have right to left associativity.

Uploaded by

adidas
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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

You might also like