# C++ Programming/Operators Table
## Table of operators

Operators in the same group have the same precedence and the order of evaluation is decided by the associativity (left-to-right or right-to-left). Operators in a preceding group have higher precedence than those in a subsequent group.
| Operators | Description | Example Usage | Associativity |
| Scope Resolution Operator | Scope Resolution Operator | Scope Resolution Operator | — |
| :: | unary scope resolution operator for globals | ::NUM_ELEMENTS | — |
| :: | binary scope resolution operator for class and namespace members | std::cout | — |
| Function Call, Member Access, Post-Increment/Decrement Operators, RTTI and C++ Casts | Function Call, Member Access, Post-Increment/Decrement Operators, RTTI and C++ Casts | Function Call, Member Access, Post-Increment/Decrement Operators, RTTI and C++ Casts | Left to right |
| | function call operator | swap (x, y) | Left to right |
| | array index operator | arr [i] | Left to right |
| . | member access operator for an object of class/union type or a reference to it | obj.member | Left to right |
| -> | member access operator for a pointer to an object of class/union type | ptr->member | Left to right |
| ++ -- | post-increment/decrement operators | num++ | Left to right |
| typeid | run time type identification operator for an object or type | typeid (std::cout) typeid (std::iostream) | Left to right |
| static_cast<> dynamic_cast<> const_cast<> reinterpret_cast<> | C++ style cast operators for compile-time type conversion See Type Casting for more info | static_cast<float> (i) dynamic_cast<std::istream> (stream) const_cast<char*> ("Hello, World!") reinterpret_cast<const long*> ("C++") | Left to right |
| type | functional cast operator (static_cast is preferred for conversion to a primitive type) | float (i) | Left to right |
| type | also used as a constructor call for creating a temporary object, esp. of a class type | std::string ("Hello, world!", 0, 5) | Left to right |
| Unary Operators | Unary Operators | Unary Operators | Right to left |
| !, not | logical not operator | !eof_reached | Right to left |
| ~, compl | bitwise not operator | ~mask | Right to left |
| + - | unary plus/minus operators | -num | Right to left |
| ++ -- | pre-increment/decrement operators | ++num | Right to left |
| &, bitand | address-of operator | &data | Right to left |
| * | indirection operator | *ptr | Right to left |
| new new new new | new operators for single objects or arrays | new std::string (5, '*') new int [100] new (raw_mem) int new (arg1, arg2) int [100] | Right to left |
| delete delete | delete operator for pointers to single objects or arrays | delete ptr delete arr | Right to left |
| sizeof sizeof | sizeof operator for expressions or types | sizeof 123 sizeof (int) | Right to left |
| (type) | C-style cast operator (deprecated) | (float)i | Right to left |
| Member Pointer Operators | Member Pointer Operators | Member Pointer Operators | Right to left |
| .* | member pointer access operator for an object of class/union type or a reference to it | obj.*memptr | Right to left |
| ->* | member pointer access operator for a pointer to an object of class/union type | ptr->*memptr | Right to left |
| Multiplicative Operators | Multiplicative Operators | Multiplicative Operators | Left to right |
| * / % | multiplication, division and modulus operators | celsius_diff * 9 / 5 | Left to right |
| Additive Operators | Additive Operators | Additive Operators | Left to right |
| + - | addition and subtraction operators | end - start + 1 | Left to right |
| Bitwise Shift Operators | Bitwise Shift Operators | Bitwise Shift Operators | Left to right |
| << >> | left and right shift operators | bits << shift_len bits >> shift_len | Left to right |
| Relational Inequality Operators | Relational Inequality Operators | Relational Inequality Operators | Left to right |
| < > <= >= | less-than, greater-than, less-than or equal-to, greater-than or equal-to | i < num_elements | Left to right |
| Relational Equality Operators | Relational Equality Operators | Relational Equality Operators | Left to right |
| == !=, not_eq | equal-to, not-equal-to | choice != 'n' | Left to right |
| Bitwise And Operator | Bitwise And Operator | Bitwise And Operator | Left to right |
| &, bitand | | bits & clear_mask_complement | Left to right |
| Bitwise Xor Operator | Bitwise Xor Operator | Bitwise Xor Operator | Left to right |
| ^, xor | | bits ^ invert_mask | Left to right |
| Bitwise Or Operator | Bitwise Or Operator | Bitwise Or Operator | Left to right |
| |, bitor | | bits | set_mask | Left to right |
| Logical And Operator | Logical And Operator | Logical And Operator | Left to right |
| &&, and | | arr != 0 && arr->len != 0 | Left to right |
| Logical Or Operator | Logical Or Operator | Logical Or Operator | Left to right |
| ||, or | | arr == 0 || arr->len == 0 | Left to right |
| Conditional Operator | Conditional Operator | Conditional Operator | Right to left |
| ?: | | size >= 0 ? size : 0 | Right to left |
| Assignment Operators | Assignment Operators | Assignment Operators | Right to left |
| = | assignment operator | i = 0 | Right to left |
| += -= *= /= %= &=, and_eq |=, or_eq ^=, xor_eq <<= >>= | shorthand assignment operators (foo op= bar represents foo = foo op bar) | num /= 10 | Right to left |
| Exceptions | Exceptions | Exceptions | — |
| throw | | throw "Array index out of bounds" | — |
| Comma Operator | Comma Operator | Comma Operator | Left to right |
| , | | i = 0, j = i + 1, k = 0 | Left to right |