表 5.4. 操作符的优先级

Associativity
and Operator

操作符及其结合性

Function

功能

Use

用法

See
Page

参见页码

L

::

global scope(全局作用域)

:: name

p. 450

L

::

class scope(类作用域)

class :: name

p. 85

L

::

namespace scope(名字空间作用域)

namespace :: name

p. 78

L

.

member selectors(成员选择)

object . member

p. 25

L

->

member selectors(成员选择)

pointer -> member

p. 164

L

[]

subscript(下标)

variable [ expr ]

p. 113

L

()

function call(函数调用)

name (expr_list)

p. 25

L

()

type construction(类型构造)

type (expr_list)

p. 460

R

++

postfix increment(后自增操作)

lvalue++

p. 162

R

--

postfix decrement(后自减操作)

lvalue--

p. 162

R

typeid

type ID(类型 ID)

typeid (type)

p. 775

R

typeid

run-time type ID(运行时类型 ID)

typeid (expr)

p. 775

R

explicit cast(显式强制类型转换)

type conversion(类型转换)

cast_name <type>(expr)

p. 183

R

sizeof

size of object(对象的大小)

sizeof expr

p. 167

R

sizeof

size of type(类型的大小)

sizeof(type)

p. 167

R

++

prefix increment(前自增操作)

++ lvalue

p. 162

R

--

prefix decrement(前自减操作)

-- lvalue

p. 162

R

~

bitwise NOT(位求反)

~expr

p. 154

R

!

logical NOT(逻辑非)

!expr

p. 152

R

-

unary minus(一元负号)

-expr

p. 150

R

+

unary plus(一元正号)

+expr

p. 150

R

*

dereference(解引用)

*expr

p. 119

R

&

address-of(取地址)

&expr

p. 115

R

()

type conversion(类型转换)

(type) expr

p. 186

R

new

allocate object(创建对象)

new type

p. 174

R

delete

deallocate object(释放对象)

delete expr

p. 176

R

delete[]

deallocate array(释放数组)

delete[] expr

p. 137

L

->*

ptr to member select(指向成员操作的指针)

ptr ->* ptr_to_member

p. 783

L

.*

ptr to member select(指向成员操作的指针)

obj .*ptr_to_member

p. 783

L

*

multiply(乘法)

expr * expr

p. 149

L

/

divide(除法)

expr / expr

p. 149

L

%

modulo (remainder)(求模(求余))

expr % expr

p. 149

L

+

add(加法)

expr + expr

p. 149

L

-

subtract(减法)

expr - expr

p. 149

L

<<

bitwise shift left(位左移)

expr << expr

p. 154

L

>>

bitwise shift right(位右移)

expr >> expr

p. 154

L

<

less than(小于)

expr < expr

p. 152

L

<=

less than or equal(小于或等于)

expr <= expr

p. 152

L

>

greater than(大于)

expr > expr

p. 152

L

>=

greater than or equal(大于或等于)

expr >= expr

p. 152

L

==

equality(相等)

expr == expr

p. 152

L

!=

inequality(不等)

expr != expr

p. 152

L

&

bitwise AND(位与)

expr & expr

p. 154

L

^

bitwise XOR()

expr ^ expr

p. 154

L

|

bitwise OR(位异或)

expr | expr

p. 154

L

&&

logical AND(逻辑与)

expr && expr

p. 152

L

||

logical OR(逻辑或)

expr || expr

p. 152

R

?:

conditional(条件操作)

expr ? expr : expr

p. 165

R

=

assignment(赋值操作)

lvalue = expr

p. 159

R

*=, /=, %=,

compound assign(复合赋值操作)

lvalue += expr, etc.

p. 159

R

+=, -=,

   

p. 159

R

<<=, >>=,

   

p. 159

R

&=,|=, ^=

   

p. 159

R

throw

throw exception(抛出异常)

throw expr

p. 216

L

,

comma(逗号)

expr , expr

p. 168

来自《C++ Primer,Fourth Edition》