C ++的运算符优先级
来源:互联网 发布:淘宝网 卖t恤是真吗 编辑:程序博客网 时间:2024/04/28 23:48
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()
Function call[]
Array subscripting.
Element selection by reference->
Element selection through pointertypeid()
Run-time type information (seetypeid)const_cast
Type cast (see const_cast)dynamic_cast
Type cast (see dynamic_cast)reinterpret_cast
Type cast (seereinterpret_cast)static_cast
Type cast (see static_cast)++
--
Prefix increment and decrementRight-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/modulus[1]+
-
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 (exceptions throwing),
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 expression std::cout<<a&b is parsed as (std::cout<<a)&b and not std::cout<<(a&b).
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 expressions *p++ and a=b=c are parsed as *(p++) and a=(b=c), and not as (*p)++ or (a=b)=c because of right-to-left associativity.
An operator's precedence is unaffected by overloading.
- ↑ ISO/IEC 14882:2003 : Programming languages -- C++. "the binary % operator yields the remainder from the division of the first expression by the second. .... If both operands are nonnegative then the remainder is nonnegative; if not, the sign of the remainder is implementation-defined".
- C ++的运算符优先级
- C++/C运算符的优先级
- 运算符的优先级(c#,c,java)
- c 运算符 优先级
- c 运算符 优先级
- C运算符优先级
- c运算符优先级
- C运算符优先级
- C运算符优先级
- C运算符优先级
- c运算符优先级
- c运算符优先级
- C运算符优先级
- C运算符优先级
- C运算符优先级
- C运算符优先级
- c运算符优先级
- C 运算符优先级
- Google Megastore读写的架构分析
- TCP/IP协议
- jdk hibernate spring 等下载地址... 更新中...
- 浮在水面,沉在水底
- 近思
- C ++的运算符优先级
- 怎样取消IBM笔记本电脑的桌面扩展功能?
- C语言初学者的困惑--如何由dos向windows转变
- Eclipse目录下features和plugins文件夹的区别
- Ubuntu开机加速
- C#使用 StringBuilder 类
- SQL中CASE的用法
- ASCII表格
- Eclipse插件安装方法