C++ Expressions in Increasing Order of Precedence



Signature/Syntax Sample Name/Semantics


Lowest precedence left associative entry
right associative entry


expr, expr sequencing (comma)


throw expr throw expression


lvalue = expr simple assignment
lvalue *= expr multiply and assign
lvalue /= expr divide and assign
lvalue %= expr modulo and assign
lvalue += expr add and assign
lvalue -= expr
subtract and assign
lvalue <<= expr shift left and assign
lvalue >>= expr shift right and assign
lvalue &= expr bit AND and assign
lvalue ^= expr bit XOR and assign
lvalue |= expr bit OR and assign


expr ? expr : expr if-then-else expr


expr or expr
expr || expr
logical inclusive or


expr and expr
expr && expr
logical and


expr | expr bitwise OR


expr ^ expr bitwise XOR


expr & expr bitwise AND


expr == expr
expr != expr
equal,
not equal


expr < expr
expr <= expr
expr > expr
expr >= expr
less than,
less than or equal,
greater than,
greater than or equal


expr << expr
expr >> expr
shift left,
shift right


expr + expr
expr - expr
add (plus),
subtract (minus)


expr * expr
expr / expr
expr % expr
multiply,
divide,
mod (remainder)


object .* ptr_to_data_member   member selection  
object ->* ptr_to_fun_member   member selection


sizeof (type) size of type
sizeof expr size of expr type
++ lvalue pre increment
-- lvalue pre decrement
~ expr bitwise NOT
not expr logical not
! expr logical not
+ expr unary plus
- expr unary minus
& lvalue address of
* expr dereference
new type create
new type (expr_list) create
new (expr_list) type create (placement)
new (expr_list) type (expr_list) create (placement)
new type [ expr ] create array
delete pointer destroy object
delete [ ]  pointer destroy array
(type) expr type cast


object . member member selection
pointer -> member member selection
pointer [ expr ] subscripting
function ( expr_list ) function call
type ( expr_list ) value construction
lvalue ++ post increment
lvalue -- post decrement
typeid (type) type identification
typeid (expr) run-time type
dynamic_cast <type> (expr) run-time conversion
static_cast <type> (expr) compile-time conversion
reinterpret_cast <type> (expr) unchecked conversion
const_cast <type> (expr) const conversion


class_name :: name
namespace_name :: name
:: global_name
:: qualified_name
scope resolution
scope resolution
global
global


Highest Precedence