Operator priority summary in C/C ++

Source: Internet
Author: User

Operators in C Language

Description Operator Associativity
Elementary Operators () []->. ->
Single Object Operator ! ~ ++ ---(Type) * & sizeof <-
Arithmetic Operators */% ->
Arithmetic Operators +- ->
Shift Operator <> ->
Relational operators >>=< = ->
Relational operators =! = ->
Bitwise AND & ->
Bitwise OR ^ ->
By bit or | ->
Logic and && ->
Logic or | ->
Conditional Operators ? : <-
Value assignment operator = + =-= * =/= % = <= >>=& = ^ = | = <-
Comma Operator , ->

Operators in C ++

Operator Description Associativity
:: Binary scope, unary Scope ->

() []. -> ++ --
typeid
dynamic_cast
static_cast
reinterpret_cast const_cast

elementary/type conversion
++ -- auto-increment after one dollar
->
++ -- + -! ~ (Type) sizeof &*
New [] delete Delete []
++ -- Auto-increment before one dollar <-
. *-> * Pointer to a member ->
*/% Arithmetic Operators ->
+- Arithmetic Operators ->
<> Shift Operator ->
<=> = Relational operators ->
=! = Relational operators ->
& Bitwise AND ->
^ Bitwise OR ->
| By bit or ->
&& Logic and ->
| Logic or ->
? : Conditional Operators <-
= + =-= * =/= % = <=> = Value assignment operator <-
, Comma Operator ->

note: the priority decreases from top to bottom!
conclusion! (Please remember this sentence, though not quite satisfactory)
girls do not cry (QQ: 191035066) @ cnblogs @ 2011-12-29 11:01:10
http://www.cnblogs.com/nbsofer/archive/2011/12/29/2305766.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.