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.
PrecedenceOperatorDescriptionAssociativity1::Scope resolutionLeft-to-right2++ --Suffix/postfix increment and decrement()Function call[]Array subscripting.Element selection by reference−>Element selection through pointer3++ --Prefix increment and decrementRight-to-left+ −Unary plus and minus! ~Logical NOT and bitwise NOT(type)Type cast*Indirection (dereference)&Address-ofsizeofSize-ofnew, new[]Dynamic memory allocationdelete, delete[]Dynamic memory deallocation4.* ->*Pointer to memberLeft-to-right5* / %Multiplication, division, and remainder6+ −Addition and subtraction7<< >>Bitwise left shift and right shift8< <=For relational operators < and ≤ respectively> >=For relational operators > and ≥ respectively9== !=For relational = and ≠ respectively10&Bitwise AND11^Bitwise XOR (exclusive or)12|Bitwise OR (inclusive or)13&&Logical AND14||Logical OR15?: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 OR16throwThrow operator (for exceptions)17,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 is parsed as (std::cout<<a)&b, not asstd::cout<<(a&b).the expressions *p++ is parsed as *(p++), not (*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语言中,运算符的运算优先级共分为15级。1级最高,15级最低。在表达式中,优先级较高的先于优先级较低的进行运算。 而在一个运算量两侧的运算符优先级相同时, 则按运算符的结合性所规定的结合方向处理。 C语言中各运算符的结合性分为两种,即左结合性(自左至右)和右结合性(自右至左)。例如算术运算符的结合性是自左至右,即先左后右。如有表达式x-y+z则y应先与“-”号结合, 执行x-y运算,然后再执行+z的运算。这种自左至右的结合方向就称为“左结合性”。而自右至左的结合方向称为“右结合性”。 最典型的右结合性运算符是赋值运算符。如x=y=z,由于“=”的右结合性,应先执行y=z再执行x=(y=z)运算。
转载于:https://www.cnblogs.com/shangdawei/archive/2013/06/15/3137916.html
相关资源:数据结构—成绩单生成器