Alibabacloud.com offers a wide variety of articles about precedence and associativity, easily find your precedence and associativity information here online.
introduced:The C and Pointers P83 page has an example: A*b+c*d+e*f, and for this example, the precedence and binding of the operator are explained. To facilitate the following instructions, we have numbered the operators in the above expressions:
The two priorities are the same, and the comparison (comparision) and Assignment (Assignment) operations are slightly different. The comparison operator has a, =, and so on, the assignment operator has =, + =, *=, and so on.
The comparison
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
Generally, operators have a set of precedence, that is, the order in which they are executed.Operators also have associativity, which is the order in which operators of the same precedence are executed. This order is usually left-to-right (left),
Precedence
Operator
Description
Example
associativity
1
()[]-.::++--
Grouping operatorArray AccessMember access from a pointerMember access from a objectScoping operatorPost-incrementPost-decrement
(A
C + + Operator precedence
The operators at the top of this list are evaluated.
Precedence
Operator
Description
Example
associativity
1
::
Scoping operator
Class::age = 2;
None
2
ArticleDirectory
C ++ operator precedence
C ++ operator precedence
The operators at the top of this list are evaluated first.
Precedence
Operator
Description
Example
Associativity
1
::
Priority level
operator
description
examples
of associativity
1
()[]-.::++--
The parentheses operator that adjusts the precedenceArray Subscript access operatorTo access a member's operator by
Summary:This paper is a pioneering analysis of the role of sequence points in the evaluation of C-language expressions: The operand to the left of the sequence point is evaluated before its right operand. The comma operator, logic and operator &&,
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.