The precedence of C + + operator and its memory method __c++

Source: Internet
Author: User
Tags bitwise
Priority Level operator Description Example combination of
1 ()
[]
->
.
::
++
--
Bracket operator for adjusting precedence
Array Subscript access operator
To access a member's operator by pointing to an object's pointer
To access a member's operator through the object itself
Scope operator
Post self-increment operator
Post Self subtraction operator
(A + B)/4;
ARRAY[4] = 2;
Ptr->age = 34;
Obj.age = 34;
Class::age = 2;
for (i = 0; i < i++) ...
for (i = i > 0; i--) ...
From left to right
2 !
~
++
--
-
+
*
&
(type)
sizeof
Logical fetch inverse operator
Bitwise reverse (by bit to fill)
Forward self-increment operator
Forward self-subtraction operator
Unary take negative operator
Unary take positive operator
Solution Reference operator
Take address operator
Type conversion operators
Returns the number of bytes used by the object operator
if (!done) ...
Flags = ~flags;
for (i = 0; i < ++i) ...
for (i = 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 ->*
.*
To access a member's operator on the pointer by a pointer to a member
To access a member's operator on an object by pointing to a pointer to a member
Ptr->*var = 24;
Obj.*var = 24;
From left to right
4 *
/
%
Multiplication operator
Division operator
Take the remainder operator
int i = 2 * 4;
float F = 10/3;
int rem = 4% 3;
From left to right
5 +
-
Addition operator
Subtraction operator
int i = 2 + 3;
int i = 5-1;
From left to right
6 <<
>>
Bitwise left-shift operator
Bitwise right-shift operator
int flags = << 1;
int flags = >> 1;
From left to right
7 <
<=
>
>=
Less than comparison operator
Less than or equal to comparison operator
Greater than comparison operator
Greater than or equal to comparison operator
if (I < 42) ...
if (i <= 42) ...
if (i > 42) ...
if (i >= 42) ...
From left to right
8 ==
!=
equals comparison operator
Not equal to comparison operator
if (i = = 42) ...
if (i!= 42) ...
From left to right
9 & Bitwise AND operator Flags = flags & 42; From left to right
10 ^ Bitwise XOR OR operator Flags = flags ^ 42; From left to right
11 | Bitwise OR operator Flags = Flags | 42; From left to right
12 && Logic and operators if (Conditiona && conditionb) ... From left to right
13 || Logical OR operator if (Conditiona | | conditionb) ... From left to right
14 ? : Ternary conditional operator int i = (a > B)? A:B; From right to left
15 =
+=
-=
*=
/=
%=
&=
^=
|=
<<=
>>=
Assignment operator
Compound assignment Operator (addition)
Compound assignment operator (subtraction)
Compound assignment operator (multiplication)
Compound assignment Operator (division)
Compound assignment operator (remainder)
Compound assignment operators (bitwise AND)
Compound assignment operator (bitwise XOR OR)
Compound assignment operator (bitwise OR)
Compound assignment operator (move left by bit)
Compound assignment operator (move 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 < i++, j + +) ... From 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.