C + + Symbol priority (detailed collation) _c language

Source: Internet
Author: User
Tags bitwise int size
Precedence Operator Description Example associativity
1 ()
[]
->
.
::
++
--
Grouping operator
Array Access
member access from a pointer
member access from an object
Scoping operator
Post-increment
Post-decrement
(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--) ...
Left to right
2 !
~
+ +
--
-
+
*
/
(type)
sizeof
logical negation
Bitwise complement
Pre-increment
Pre-decrement
Unary minus
Unary plus
dereference
Address of
Cast to a given type
return size in bytes
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);
right to left
3 ->*
.*
Member Pointer selector
Member Pointer selector
Ptr->*var = 24;
Obj.*var = 24;
Left to right
4 *
/
%
Multiplication
Division
Modulus
int i = 2 * 4;
float F = 10/3;
int rem = 4% 3;
Left to right
5 +
-
Addition
Subtraction
int i = 2 + 3;
int i = 5-1;
Left to right
6 <<
>>
Bitwise SHIFT LEFT
Bitwise SHIFT Right
int flags = << 1;
int flags = >> 1;
Left to right
7 <
<=
>
>=
Comparison Less-than
Comparison less-than-or-equal-to
Comparison Greater-than
Comparison geater-than-or-equal-to
if (I < 42) ...
if (i <= 42) ...
if (i > 42) ...
if (i >= 42) ...
Left to right
8 ==
!=
Comparison equal-to
Comparison not-equal-to
if (i = = 42) ...
if (i!= 42) ...
Left to right
9 & Bitwise AND Flags = flags & 42; Left to right
10 ^ Bitwise EXCLUSIVE OR Flags = flags ^ 42; Left to right
11 | Bitwise inclusive (normal) OR Flags = Flags | 42; Left to right
12 && Logical and if (Conditiona && conditionb) ... Left to right
13 || Logical OR if (Conditiona | | conditionb) ... Left to right
14 ternary Conditi Onal (if-then-else) int i = (a > B)? a:b; right to left
15 =
+ =
-=
*=
/=
% =
&=
^=
|=
<<=
>>=
assignment operator
Increment and assign
Decrement and assign
Multiply and assign
Divide and assign
modulo and assign
bitwise AND and assign
Bitwis E exclusive OR and assign
Bitwise inclusive (normal) or and assign
bitwise shift LEFT and assign
bitwise shift RI Ght and assign
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;
right to left
16 sequential Evaluation operator for (i = 0, j = 0; I < i++, j + +) ... left to right
Related Article

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.