Precedence and binding of C + + operators __c++

Source: Internet
Author: User
Tags bitwise

Precedence and binding of operators

Priority Level

operator

name or meaning

Use Form

Combining Direction

Description

1

Post + +

Post Self-add operator

Variable name + +

Left to right

Post--

Back-up self-subtraction operators

Variable name--



[ ]

Array subscript

array name [INT-expression]



( )

Parentheses

(expression)/function name (formal parameter list)

.

Member selection (object)

Object. Member name

->

Member selection (pointers)

Object pointer-> member name

2

-

Minus sign operator

-An expression

Right to Left

Monocular operator

Type

Force type conversions

(data type) expression

Predecessor + +

Forward self-add operator

+ + variable Name

Monocular operator

Predecessor--

Forward self-subtraction operator

--Variable name

Monocular operator

*

Value operator

* Pointer expression

Monocular operator

&

Take address operator

& Left-Value expression

Monocular operator

!

Logical non-operator

! An expression

Monocular operator

~

Bitwise inverse operator

~ Expression

Monocular operator

sizeof

Length operator

sizeof expression/sizeof (type)

3

/

Except

An expression/expression

Left to right

Binocular operator

*

By

Expression * Expression

Binocular operator

%

Remainder (modulo)

Integral expression% integer expression

Binocular operator

4

+

Add

expression + expression

Left to right

Binocular operator

-

Reducing

Expression-An expression

Binocular operator

5

<<

Move left

Expressions << Expressions

Left to right

Binocular operator

>>

Move right

Expressions >> Expressions

Binocular operator

6

>

Greater than

Expressions > expressions

Left to right

Binocular operator

>=

Greater than or equal to

Expression >= An expression

Binocular operator

<

Less than

Expressions < expressions

Binocular operator

<=

Less than or equal to

Expression <= An expression

Binocular operator

7

==

Equals

expression = = Expression

Left to right

Binocular operator

!=

Not equal to

Expression!= An expression

Binocular operator

8

&

Bitwise AND

Integral Expressions & Integer expressions

Left to right

Binocular operator

9

^

Per-bitwise XOR OR

Integral expression ^ integral expression

Left to right

Binocular operator

Ten

|

by bit or

Integral expression | Integral expression

Left to right

Binocular operator

One

&&

Logic and

Expressions && Expressions

Left to right

Binocular operator

of

||

Logical OR

expression | | An expression

Left to right

Binocular operator

of

?:

Conditional operator

Expression 1-expression 2: Expression 3

Right to Left

Three-mesh operator

-

=

Assignment operator

variable = expression

Right to Left

/=

Assign value in addition to

Variable/= expression

*=

After multiplication assign value

Variable *= expression

%=

To assign a value after taking a model

Variable%= expression

+=

Add and then assign value

Variable = = Expression

-=

After minus assignment

Variable-= expression

<<=

Assign values after left shift

Variable <<= expression

>>=

Assign value after right shift

Variable >>= expression

&=

Bitwise AND Post-assignment

Variable &= expression

^=

Assign values by bitwise OR after

Variable ^= expression

|=

Bitwise OR post-value assignment

Variable |= expression

-

,

Comma operator

expressions, Expressions,...

Left to right

Order from left to right

* Priority one column number smaller priority greater

Reference:

Baidu Encyclopedia

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.