C++ Operators
C++ operator is a symbol that is used to perform mathematical or logical manipulations. C++ language is rich with built-in operators.
Arithmetic Operators
| Operator | Description |
| + | Addition |
| – | Subtraction |
| * | Multiplication |
| / | Division |
| % | Modulus |
Increment and Decrement Operators
| Operator | Description |
| ++ | Increment |
| −− | Decrement |
Relational Operators
| Operator | Description |
| == | Is equal to |
| != | Is not equal to |
| > | Greater than |
| < | Less than |
| >= | Greater than or equal to |
| <= | Less than or equal to |
Logical Operators
| Operator | Description |
| && | And operator. Performs a logical conjunction on two expressions. (if both expressions evaluate to True, result is True. If either expression evaluates to False, result is False) |
| || | Or operator. Performs a logical disjunction on two expressions. (if either or both expressions evaluate to True, result is True) |
| ! | Not operator. Performs logical negation on an expression. |
Bitwise Operators
| Operator | Description |
| << | Binary Left Shift Operator |
| >> | Binary Right Shift Operator |
| ~ | Binary Ones Complement Operator |
| & | Binary AND Operator |
| ^ | Binary XOR Operator |
| | | Binary OR Operator |
Assignment Operators
| Operator | Description |
| = | Assign |
| += | Increments, then assigns |
| -= | Decrements, then assigns |
| *= | Multiplies, then assigns |
| /= | Divides, then assigns |
| %= | Modulus, then assigns |
| <<= | Left shift and assigns |
| >>= | Right shift and assigns |
| &= | Bitwise AND assigns |
| ^= | Bitwise exclusive OR and assigns |
| |= | Bitwise inclusive OR and assigns |
Misc Operators
| Operator | Description |
| , | Comma operator |
| sizeof() | Returns the size of an memory location. |
| & | Returns the address of an memory location. |
| * | Pointer to a variable. |
| ? : | Conditional Expression |
No comments:
Post a Comment