Operator |
Meaning |
Associativity |
Use |
:: :: |
global scope class or namespace scope |
right to left left to right |
::symbol ns::member |
. -> [] () () ++ -- |
direct member indirect member subscript call operator construction postfix increment postfix decrement |
left to right left to right left to right left to right left to right left to right left to right |
obj.member ptr->member array[index] f() constructor() i++ i-- |
sizeof ++ -- typeid const_cast dynamic_cast reinterpret_cast static_cast () ~ ! - + & * new new [] delete delete [] |
size in bytes prefix increment prefix decrement type identification constant cast dynamic cast reinterpret cast static cast c-style cast bitwise NOT logical NOT unary minus unary plus address of operator dereference operator construct object construct array destroy object destroy array |
right to left right to left right to left right to left right to left right to left right to left right to left right to left right to left right to left right to left right to left right to left right to left right to left right to left right to left right to left |
sizeof(symbol) ++i --i typeid(obj) const_cast<type> dynamic_cast<type> reinterpret_cast<type> static_cast<type> (type)symbol ~i !b -i +i &symbol *ptr new type new type[] delete ptr delete [] ptr |
.* ->* |
member dereference indirect member dereference |
left to right left to right |
obj.*ptr_to_member ptr->*ptr_to_member |
* / % |
multiplication division modulus |
left to right left to right left to right |
a * b a / b a % b |
+ - |
addition subtraction |
left to right left to right |
a + b a - b |
<< >> |
left shift right shift |
left to right left to right |
a << b a >> b |
< <= > >= |
less than less than or equal greater than greater than or equal |
left to right left to right left to right left to right |
a < b a <= b a > b a >= b |
== != |
logical EQUAL logical NOT EQUAL |
left to right left to right |
a == b a != b |
& |
bitwise AND |
left to right |
a & b |
^ |
bitwise XOR |
left to right |
a ^ b |
| |
bitwise OR |
left to right |
a | b |
&& |
logical AND |
left to right |
a && b |
|| |
logical OR |
left to right |
a || b |
?: |
conditional expression |
left to right |
a ? b : c |
= *= /= %= += -= <<= >>= &= |= ^= |
assignment multiply update divide update modulus update add update subtract update left shift update right shift update bitwise AND update bitwise OR update bitwise XOR update |
right to left right to left right to left right to left right to left right to left right to left right to left right to left right to left right to left |
a = b a *= b a /= b a %= b a += b a -= b a <<= b a >>= b a &= b a |= b a ^= b |
throw |
throw exception |
right to left |
throw obj |
, |
comma |
left to right |
a , b |