Operator in C++
Operators are the symbols which represent various computations(such as addition, subtraction,etc.) performed on various data item. These data item on which operators act are known as operands.
Types of Operator.
The C++ operators can be classified into various categories.
- Arithmetic Operators
- Relational Operators
- Bitwise Operators
- Logical Operators
- Ternary or Conditional Operator
- Assignment Operator
- Unary operator
- Misc Operator
Precedence & Associativity of C++ operators is given below:
Category |
Operator |
Associativity |
Postfix |
() [] -> . ++ - - |
Left to right |
Unary |
+ - ! ~ ++ - - (type)* & sizeof |
Right to left |
Multiplicative |
* / % |
Left to right |
Additive |
+ - |
Right to left |
Shift |
<< >> |
Left to right |
Relational |
< <= > >= |
Left to right |
Equality |
== !=/td>
| Right to left |
Bitwise AND |
& |
Left to right |
Bitwise XOR |
^ |
Left to right |
Bitwise OR |
| |
Right to left |
Logical AND |
&& |
Left to right |
Logical OR |
|| |
Left to right |
Conditional |
?: |
Right to left |
Assignment |
= += -= *= /= %=>>= <<= &= ^= |= |
Right to left |
Comma |
, |
Left to right |
Example :
|