C + +-Operator precedence

Source: Internet
Author: User
Tags bitwise

The following table lists the precedence and associativity of C + + operators. Operators is listed top to bottom, in descending precedence.

Precedence Operator Description associativity
1 :: Scope resolution Left-to-right
2 ++-- Suffix/postfix Increment and decrement
type()type{} Function-style Type Cast
() Function Call
[] Array subscripting
. Element Selection by reference
-> Element selection through pointer
3 ++-- Prefix Increment and decrement Right-to-left
+- Unary Plus and minus
!~ Logical not and bitwise not
(type) C-style Type Cast
* indirection (dereference)
& address-of
sizeof size-of
new,new[] Dynamic Memory allocation
delete,delete[] Dynamic Memory deallocation
4 .*->* Pointer to Member Left-to-right
5 */% Multiplication, division, and remainder
6 +- Addition and subtraction
7 <<>> Bitwise left shift and right shift
8 <<= For relational operators < and≤respectively
>>= For relational operators > and≥respectively
9 ==!= For relational = and≠respectively
10 & Bitwise and
11 ^ Bitwise XOR (exclusive OR)
12 | Bitwise or (inclusive or)
13 && Logical and
14 || Logical OR
15 ?: Ternary conditional Right-to-left
= Direct assignment (provided by default for C + + classes)
+=-= Assignment by Sum and difference
*=/=%= Assignment by product, quotient, and remainder
<<=>>= Assignment by bitwise left SHIFT and right shift
&=^=|= Assignment by bitwise AND, XOR, and OR
16 throw Throw operator (for exceptions)
17 , Comma Left-to-right

C + +-Operator precedence

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.