C++ 运算符优先级
来源:互联网 发布:阿里云虚拟服务器 编辑:程序博客网 时间:2024/05/21 14:47
http://en.cppreference.com/w/cpp/language/operator_precedence
The following table lists the precedence and associativity of C++ operators. Operators are listed top to bottom, in descending precedence.
::
Scope resolutionLeft-to-right++
--
Suffix/postfix increment and decrement (a++)()
Function call[]
Array subscripting.
Element selection by reference−>
Element selection through pointer++
--
Prefix increment and decrement (++a)Right-to-left+
−
Unary plus and minus!
~
Logical NOT and bitwise NOT(type)
Type cast*
Indirection (dereference)&
Address-ofsizeof
Size-ofnew
, new[]
Dynamic memory allocationdelete
, delete[]
Dynamic memory deallocation.*
->*
Pointer to memberLeft-to-right*
/
%
Multiplication, division, and remainder+
−
Addition and subtraction<<
>>
Bitwise left shift and right shift<
<=
For relational operators < and ≤ respectively>
>=
For relational operators > and ≥ respectively==
!=
For relational = and ≠ respectively&
Bitwise AND^
Bitwise XOR (exclusive or)|
Bitwise OR (inclusive or)&&
Logical AND||
Logical OR?:
Ternary conditionalRight-to-left=
Direct assignment (provided by default for C++ classes)+=
−=
Assignment by sum and difference*=
/=
%=
Assignment by product, quotient, and remainder<<=
>>=
Assignment by bitwise left shift and right shift&=
^=
|=
Assignment by bitwise AND, XOR, and ORthrow
Throw operator (for exceptions),
CommaLeft-to-rightWhen parsing an expression, an operator which is listed on some row will be bound tighter (as if by parentheses) to its arguments than any operator that is listed on a row further below it. For example, the expressions std::cout<<a&b and *p++ are parsed as (std::cout<<a)&b and *(p++), and not asstd::cout<<(a&b) or (*p)++.
Operators that are in the same cell (there may be several rows of operators listed in a cell) are evaluated with the same precedence, in the given direction. For example, the expression a=b=c is parsed as a=(b=c), and not as (a=b)=c because of right-to-left associativity.
An operator's precedence is unaffected by overloading.
- c 运算符 优先级
- c 运算符 优先级
- C运算符优先级
- c运算符优先级
- C运算符优先级
- C运算符优先级
- C运算符优先级
- c运算符优先级
- c运算符优先级
- C运算符优先级
- C运算符优先级
- C运算符优先级
- C运算符优先级
- c运算符优先级
- C 运算符优先级
- C运算符优先级
- c 运算符 优先级
- C运算符优先级
- iReport按钮灰色 失效解决方法
- Ubuntu/linux下最强大的下载工具-aria2
- Flex4破解在MyEclipse10.0之间插件轻松集成详解
- openmp并行嵌套实例
- c语言截取字符串中的某段字符串
- C++ 运算符优先级
- poj 1847最短路flody
- 单步调试
- 1——9行的杨辉三角(C程序)
- 汇编学习笔记-赋值-loop
- 解决eclipse/Myeclipse内存不足
- vs2005中给新建项目添加静态链接库文件
- span元素
- linux挂载命令