L 一扔三四点
global scope(全局作用域) :: name
class scope(类作用域) class :: name
namespace scope(名字空间作用域) class :: name
L 成员来挑选,数索函调类型造 后面加加减减类型id明显转
member selectors(成员选择) object . member
member selectors(成员选择) pointer -> member
subscript(下标) variable [ expr ]
function call(函数调用) name (expr_list)
postfix increment(后自增操作) lvalue++
postfix decrement(后自减操作) lvalue--
type construction(类型构造) type (expr_list) type{}
run-time type ID(运行时类型 ID) typeid (expr)
type conversion(类型转换) cast_name <type>(expr)
const_cast/dynamic_cast/reinterpret_cast/static_cast
R 前面加加减减逻辑反,单加单减增与删,取址解引得大小,位反才能类型转
prefix increment(前自增操作) ++lvalue
prefix decrement(前自减操作) -- lvalue
logical NOT(逻辑非) !expr
unary plus(一元正号) +expr
unary minus(一元负号) -expr
allocate object(创建对象) new type
delete deallocate object(释放对象) delete expr
delete[] deallocate array(释放数组) delete[] expr
address-of(取地址) &expr
dereference(解引用) *expr
size of type(类型的大小) sizeof(type)
size of object(对象的大小) sizeof expr
bitwise NOT(位求反) ~expr
type conversion(类型转换) (type) expr
L 成员指针来操作
ptr to member select(指向成员操作的指针) ptr ->* ptr_to_member
ptr to member select(指向成员操作的指针) obj .*ptr_to_member
L 乘除
multiply(乘法) expr * expr
divide(除法) expr / expr
modulo (remainder)(求模(求余)) expr % expr
L 加减
add(加法) expr + expr
subtract(减法) expr - expr
L 左右移
bitwise shift left(位左移) expr << expr
bitwise shift right(位右移) expr >> expr
L 大于小于
greater than(大于) expr > expr
less than(小于) expr < expr
greater than or equal(大于或等于) expr >= expr
less than or equal(小于或等于) expr <= expr
L 等不等
equality(相等) expr == expr
inequality(不等) expr != expr
L 比特与
bitwise AND(位与) expr & expr
L 比特异或
bitwise XOR(位异或) expr ^ expr
L 比特或
bitwise OR(位或) expr | expr
L 逻辑与
logical AND(逻辑与) expr && expr
L 逻辑或
logical OR(逻辑或) expr || expr
R 条件 ?:
conditional(条件操作) expr ? expr : expr
R 赋值
assignment(赋值操作) lvalue = expr
*=, /=, %=, compound assign(复合赋值操作) lvalue += expr, etc.
+=, -=,
<<=, >>=,
&=,|=, ^=
R 扔异常
throw exception(抛出异常) throw expr
L 逗号来帮忙
comma(逗号) expr , expr
Precedence | Operator | Description | Associativity |
---|---|---|---|
1 | :: | Scope resolution | Left-to-right |
2 | a++ a-- | Suffix/postfix increment and decrement | |
type() type{} | Functional cast | ||
a() | Function call | ||
a[] | Subscript | ||
. -> | Member access | ||
3 | ++a --a | Prefix increment and decrement | Right-to-left |
+a -a | Unary plus and minus | ||
! ~ | Logical NOT and bitwise NOT | ||
(type) | C-style cast | ||
*a | Indirection (dereference) | ||
&a | Address-of | ||
sizeof | Size-of[note 1] | ||
co_await | await-expression (C++20) | ||
new new[] | Dynamic memory allocation | ||
delete delete[] | Dynamic memory deallocation | ||
4 | .* ->* | Pointer-to-member | Left-to-right |
5 | a*b a/b a%b | Multiplication, division, and remainder | |
6 | a+b a-b | Addition and subtraction | |
7 | << >> | Bitwise left shift and right shift | |
8 | <=> | Three-way comparison operator (since C++20) | |
9 | < <= > >= | For relational operators < and ≤ and > and ≥ respectively | |
10 | == != | For equality operators = and ≠ respectively | |
11 | & | Bitwise AND | |
12 | ^ | Bitwise XOR (exclusive or) | |
13 | | | Bitwise OR (inclusive or) | |
14 | && | Logical AND | |
15 | || | Logical OR | |
16 | a?b:c | Ternary conditional[note 2] | Right-to-left |
throw | throw operator | ||
co_yield | yield-expression (C++20) | ||
= | Direct assignment (provided by default for C++ classes) | ||
+= -= | Compound assignment by sum and difference | ||
*= /= %= | Compound assignment by product, quotient, and remainder | ||
<<= >>= | Compound assignment by bitwise left shift and right shift | ||
&= ^= |= | Compound assignment by bitwise AND, XOR, and OR | ||
17 | , | Comma | Left-to-right |
|