The following table lists the precedence and associativity of C++ operators. Operators are listed top to bottom, in descending precedence.

Precedence Operator Description Associativity
1 :: Scope resolution Left-to-right
2 ++  -- Suffix/postfix increment and decrement
type()type{} Function-style type cast
() Function call
[] Array subscripting
. Element selection by reference
-> Element selection through pointer
3 ++  -- Prefix increment and decrement Right-to-left
+  - Unary plus and minus
!  ~ Logical NOT and bitwise NOT
(type) C-style type cast
* Indirection (dereference)
& Address-of
sizeof Size-of
new,new[] Dynamic memory allocation
delete,delete[] Dynamic memory deallocation
4 .*  ->* Pointer to member Left-to-right
5 *  /  % Multiplication, division, and remainder
6 +  - Addition and subtraction
7 <<  >> Bitwise left shift and right shift
8 <  <= For relational operators < and ≤ respectively
>  >= For relational operators > and ≥ respectively
9 ==  != For relational = and ≠ respectively
10 & Bitwise AND
11 ^ Bitwise XOR (exclusive or)
12 | Bitwise OR (inclusive or)
13 && Logical AND
14 || Logical OR
15 ?: Ternary conditional Right-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 OR
16 throw Throw operator (for exceptions)
17 , Comma Left-to-right

C++ - Operator Precedence的更多相关文章

  1. PythonStudy——运算符优先级 Operator precedence

    运算符优先级 以下所列优先级顺序按照从低到高优先级的顺序:同行为相同优先级. 1 Lambda #运算优先级最低 2 逻辑运算符: or 3 逻辑运算符: and 4 逻辑运算符:not 5 成员测试 ...

  2. [WPF系列]-DataBinding 绑定计算表达式

            Width="{Binding RelativeSource={RelativeSource Self}, Path=ActualWidth, Converter={Stat ...

  3. Spring学习总结(四)——表达式语言 Spring Expression Language

    SpEL简介与功能特性 Spring表达式语言(简称SpEL)是一个支持查询并在运行时操纵一个对象图的功能强大的表达式语言.SpEL语言的语法类似于统一EL,但提供了更多的功能,最主要的是显式方法调用 ...

  4. C语言宏定义时#(井号)和##(双井号)的用法

    C语言中如何使用宏C(和C++)中的宏(Macro)属于编译器预处理的范畴,属于编译期概念(而非运行期概念).下面对常遇到的宏的使用问题做了简单总结. 关于#和## 在C语言的宏中,#的功能是将其后面 ...

  5. 【GoLang】50 个 Go 开发者常犯的错误

    1. { 换行:   Opening Brace Can't Be Placed on a Separate Line 2. 定义未使用的变量:  Unused Variables 2. import ...

  6. 如何编写Iveely搜索引擎插件

    如果一个搜索引擎仅仅是网页搜索,那么将会是非常枯燥的,也不能根据业务需求扩展,还好Iveely在设计之初,就考虑了扩展性,预留插件功能,在不关闭服务或者停用服务的情况下,可以随时启用新插件或者禁用. ...

  7. The P4 Language Specification v1.0.2 Header and Fields

    前言 本文参考P4.org网站给出的<The P4 Language Specification v1.0.2>的第二部分首部及字段,仅供学习:). 欢迎交流! Header and Fi ...

  8. jython学习笔记2

    1.%是求余,//是整除的商,**是乘方 abs(var) Absolute value pow(x, y) Can be used in place of ** operator pow(x,y,m ...

  9. [转]50 Shades of Go: Traps, Gotchas, and Common Mistakes for New Golang Devs

    http://devs.cloudimmunity.com/gotchas-and-common-mistakes-in-go-golang/ 50 Shades of Go: Traps, Gotc ...

随机推荐

  1. CMake初步(2)

    转自:<你所不知的OSG>第一章:CMake初步(2) http://bbs.osgchina.org/forum.php?mod=viewthread&tid=1229& ...

  2. LeetCodeOJ. String to Integer (atoi)

    试题请參见: https://oj.leetcode.com/problems/string-to-integer-atoi/ 题目概述 Implement atoi to convert a str ...

  3. POJ 3422 Kaka&#39;s Matrix Travels (最小费用最大流)

    POJ 3422 Kaka's Matrix Travels 链接:http://poj.org/problem? id=3422 题意:有一个N*N的方格,每一个方格里面有一个数字.如今卡卡要从左上 ...

  4. python2.7 串口操作方式 编译 .py为windows可运行exe文件

    一 python操作串口 首先下载安装串口模块pyserial . 代码实现: import serial ser = serial.Serial('/dev/ttyUSB2', 115200) pr ...

  5. 利用ant的javac任务来编译程序使用ant的java任务来运行程序

    <?xml version="1.0" encoding="UTF-8"?> <project name="javaTest&quo ...

  6. mac下的应用程序发布 及 打包(Python写的脚本,可打包第三方库)

    其实这个问题在网上能搜到大把的解决方案.大家的统一答案都是 otool -L yourapp.app/Contents/MacOS/yourapp 根据输出信息在运行 install_name_too ...

  7. android handler looper thread

    在线程中调用包含创建handler方法的时候,会报错,提示: “need call Looper.prepare()” -- 在创建之前,调用Looper.prepare()方法来创建一个looper ...

  8. Android TextView(同时显示图片+文字)

    见上图:需要图片和文字 在一起 之前的做法是用两个控件组成 <LinearLayout> <ImageView /> <TextView /> </Linea ...

  9. 在JavaScript中也玩变量类型强行转换

    <script language="javascript">     var str = '100';     var num = Number(100);     a ...

  10. Boost 库Program Options--第二篇

    程式執行參數處理函式庫:Boost Program Options(2/N) 前一篇已經大致解釋了 Boost Program Options 基本上的使用方法.而這一篇,則來細講一下選項描述(opt ...