Dream To Me

总有些什么留下来并被惦记

C++运算符优先级

 同一优先级按结合性顺序运算


 ********************************************************************** 
 第一优先级 
 :: Scope resolution None 
 ********************************************************************** 
 第二优先级 
 . Member selection (object) Left to right 
 -> Member selection (pointer) Left to right 
 [] Array subscript Left to right 
 () Function call Left to right 
 () member initialization Left to right 
 ++ Postfix increment Left to right 
 -- Postfix decrement Left to right 
 typeid type name Left to right 
 () Type cast (conversion) Left to right 
 const_cast Type cast (conversion) Left to right 
 dynamic_cast Type cast (conversion) Left to right 
 reinterpret_cast Type cast (conversion) Left to right 
 static_cast Type cast (conversion) Left to right 
 ********************************************************************** 
 第三优先级 
 sizeof Size of object or type Right to left 
 ++ Prefix increment Right to left 
 -- Prefix decrement Right to left 
 ~ One's complement Right to left 
 ! Logical not Right to left 
 - Unary minus Right to left 
 + Unary plus Right to left 
 & Address-of Right to left 
 * Indirection Right to left 
 new Create object Right to left 
 delete Destroy object Right to left 
 () Cast Right to left 
 ********************************************************************** 
 第四优先级 
 .* Pointer-to-member (objects) Left to right 
 ->* Pointer-to-member (pointers) Left to right 
 ********************************************************************** 
 第五优先级 
 * Multiplication Left to right 
 / Division Left to right 
 % Modulus Left to right 
 ********************************************************************** 
 第六优先级 
 + Addition Left to right 
 - Subtraction Left to right 
 ********************************************************************** 
 第七优先级 
 << Left shift Left to right 
 >> Right shift Left to right 
 ********************************************************************** 
 第八优先级 
 < Less than Left to right 
 > Greater than Left to right 
 <= Less than or equal to Left to right 
 >= Greater than or equal to Left to right 
 ********************************************************************** 
 第九优先级 
 == Equality Left to right 
 != Inequality Left to right 
 ********************************************************************** 
 第十优先级 
 & Bitwise AND Left to right 
 ********************************************************************** 
 第十一优先级 
 ^ Bitwise exclusive OR Left to right 
 ********************************************************************** 
 第十二优先级 
 | Bitwise inclusive OR Left to right 
 ********************************************************************** 
 第十三优先级 
 && Logical AND Left to right 
 ********************************************************************** 
 第十四优先级 
 || Logical OR Left to right 
 ********************************************************************** 
 第十五优先级 
 e1 ? e2 : e3 Conditional Right to left 
 ********************************************************************** 
 第十六优先级 
 = Assignment Right to left 
 *= Multiplication assignment Right to left 
 /= Division assignment Right to left 
 %= Modulus assignment Right to left 
 += Addition assignment Right to left 
 -= Subtraction assignment Right to left 
 <<= Left-shift assignment Right to left 
 >>= Right-shift assignment Right to left 
 &= Bitwise AND assignment Right to left 
 |= Bitwise inclusive OR assignment Right to left 
 ^= Bitwise exclusive OR assignment Right to left 
 ********************************************************************** 
 第十七优先级 
 throw expr throw expression Right to left 
 ********************************************************************** 
 第十八优先级 
 , Comma Left to right 
 **********************************************************************