Alibabacloud.com offers a wide variety of articles about precedence and associativity in c, easily find your precedence and associativity in c 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 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
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
::
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 &&,
Precedence
Operator
Description
Example
associativity
1
()[]-.::++--
Grouping operatorArray AccessMember access from a pointerMember access from a objectScoping operatorPost-incrementPost-decrement
(A
Although, there is a certain C + + foundation (because the undergraduate has learned this kind, haha), but still decided to read the system of the book (before a few times before. Sweat).Leave it for your own reference later. (The content will be
Readers may suspect that something as simple as an if, a for, a while, a goto, or a switch should also be about programming style, is it a fuss?
I really find that many programmers write expressions and basic statements in the wrong way, and I have
+ 、-、 *,/, = Priority
1. Priority level As with mathematics, C language stipulates multiplication and subtraction before adding and reducing . In other words, the multiplication and division operators have a higher precedence
An expression
C + + provides a rich operator and defines what these operators mean when the operands are of a built-in type. In addition, C + + supports operator overloading, allowing programmers to customize the meaning of the operator when used
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.