Priority of the C ++ Operator

Source: Internet
Author: User
Priority Operator Description Example Associativity
1 ()
[]
->
.
::
++
--
Parentheses operator for priority adjustment
Array subscript access operator
Access the member operator by pointing to the object pointer
Operator for accessing members through the object itself
Scope Operator
Post auto-incrementing Operator
Post-auto-subtraction Operator
(A + B)/4;
Array [4] = 2;
PTR-> age = 34;
OBJ. Age = 34;
Class: age = 2;
For (I = 0; I <10; I ++ )...
For (I = 10; I> 0; I --)...
Left to right
2 !
~
++
--
-
+
*
&
(Type)
Sizeof
Logical anti-Operator
Bitwise inversion (bitwise population)
Pre-auto-increment operator
Front-End Auto-subtraction Operator
Negative operators for one element
Unary positive operators
Unreference Operator
Bitwise Operator
Type conversion Operator
Returns the number of bytes occupied by an object.
If (! Done )...
Flags = ~ Flags;
For (I = 0; I <10; ++ I )...
For (I = 10; I> 0; -- I )...
Int I =-1;
Int I = + 1;
Data = * PTR;
Address = & OBJ;
Int I = (INT) floatnum;
Int size = sizeof (floatnum );
From right to left
3 -> *
.*
Access the operator of a member through a pointer to the member
Access member operators through pointers to members on objects
PTR-> * Var = 24;
OBJ. * Var = 24;
Left to right
4 *
/
%
Multiplication Operator
Division Operator
Returns the remainder operator.
Int I = 2*4;
Float F = 10/3;
Int REM = 4% 3;
Left to right
5 +
-
Addition Operator
Subtraction Operator
Int I = 2 + 3;
Int I = 5-1;
Left to right
6 <
>
Bitwise left shift operator
Bitwise right shift operator
Int flags = 33 <1;
Int flags = 33> 1;
Left to right
7 <
<=
>
> =
Less than comparison operator
Less than or equal to the comparison operator
Greater than the comparison operator
Greater than or equal to the comparison operator
If (I <42 )...
If (I <= 42 )...
If (I> 42 )...
If (I> = 42 )...
Left to right
8 =
! =
Equal to the comparison operator
Not equal to the comparison operator
If (I = 42 )...
If (I! = 42 )...
Left to right
9 & Bitwise AND operator Flags = flags & 42; Left to right
10 ^ Bitwise OR operator Flags = flags ^ 42; Left to right
11 | Bitwise OR operator Flags = flags | 42; Left to right
12 && Logic and operators If (conditiona & conditionb )... Left to right
13 | Logic or operator If (conditiona | conditionb )... Left to right
14 ? : Ternary conditional Operators Int I = (A> B )? A: B; From right to left
15 =
+ =
-=
* =
/=
% =
& =
^ =
| =
<=
>>=
Value assignment operator
Compound assignment operator (addition)
Compound value assignment operator (subtraction)
Compound value assignment operator (multiplication)
Compound assignment operator (Division)
Compound value assignment operator (remainder)
Compound value assignment operator (bitwise AND)
Compound value assignment operator (bitwise XOR)
Compound value assignment operator (bitwise OR)
Compound value assignment operator (shifts left by bit)
Compound value assignment operator (shifts right by bit)
Int A = B;
A + = 3;
B-= 4;
A * = 5;
A/= 2;
A % = 3;
Flags & = new_flags;
Flags ^ = new_flags;
Flags | = new_flags;
Flags <= 2;
Flags> = 2;
From right to left
16 , Comma Operator For (I = 0, j = 0; I <10; I ++, J ++ )... Left to right

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.