27.1: Abbreviated Precedence Chart for C++ Operators
- Page ID
- 10563
An operator is a language-specific syntactical token (one or more symbols) that causes an action to be taken on one or more operands. The following item provides an abbreviated list of those C++ operators that are typically taught in a programming fundamentals course that teaches modular structured programming concepts.
The first column shows the precedence (the higher precedence is 1 or it goes first) and operators that have the same precedence also have the same associativity (the associativity is only listed once for the group of operators). Decrement is two minus signs, but some word processing software programs might have problems printing two minus signs and convert it to a double dash. Insertion (two < signs) and extraction (two > signs) might also have printing problems. These printing problems are noted in the comments with emphasized text.
PR | Operator Name | Symbol(s) | Comments | Associativity | Connexions Module |
1 | function call | () | Left to Right | m19145 | |
1 | index | [] | aka array index | m21316 | |
2 | class member | . | a period | Right to Left | m20796 |
2 | postfix increment | ++ | unary | m20499 | |
2 | postfix decrement | -- | unary, two minus signs | m20499 | |
3 | indirection | * | unary, aka dereference | Right to Left | m22152 |
3 | address | & | unary | m22148 | |
3 | unary positive | + | unary, aka plus | m20501 | |
3 | unary negative | - | unary, aka minus | m20501 | |
3 | prefix increment | ++ | unary | m20499 | |
3 | prefix decrement | -- | unary, two minus signs | m20499 | |
3 | cast | (type) | unary | m18744 | |
3 | sizeof | sizeof (type) | unary | m18736 | |
3 | logical NOT | ! | unary | m19847 | |
4 | multiply | * | Left to Right | m18706 | |
4 | divide | / | m18706 | ||
4 | modulus | % | remainder | m18706 | |
5 | add | + | Left to Right | m18706 | |
5 | subtract | - | m18706 | ||
6 | insertion | << | writing, two less than signs | Left to Right | m18835 |
6 | extraction | >> | reading, two greater than signs | m18835 | |
7 | less than | < | Left to Right | m19549 | |
7 | greater than | > | m19549 | ||
7 | less than or equal to | <= | m19549 | ||
7 | greater than or equal to | >= | m19549 | ||
8 | equality | == | equal to | Left to Right | m19549 |
8 | inequality | != | not equal to | m19549 | |
9 | logical AND | && | Left to Right | m19847 | |
10 | logical OR | || | Left to Right | m19847 | |
11 | conditional | ?: | trinary | Left to Right | m20811 |
12 | assignment | = | Right to Left | m18725 | |
12 | addition assignment | += | m18743 | ||
12 | subtraction assignment | -= | m18743 | ||
12 | multiplication assignment | *= | m18743 | ||
12 | division assignment | /= | m18743 | ||
12 | modulus assignment | %= | m18743 | ||
13 | sequence or comma | , | Left to Right | m18690 |