An operator is a symbol that tells the compiler to perform a specific mathematical or logical operation. C + + has a rich operator built into it and provides the following types of operators:
Arithmetic operators
Relational operators
C-language operator precedence and formulasThere are 15 priority levels: operators of the same precedence, and the order of operations is determined by the binding direction1 () []. --(parentheses, member row first)2! ~-(minus) + +--& (take variable
Precedence
Operator
Description
Example
associativity
1
()[]-.::++--
Grouping operatorArray AccessMember access from a pointerMember access from a objectScoping operatorPost-incrementPost-decrement
(A
In the logical operator of PHP, XOR represents a logical XOR or
$a XOR $b
Results
Returns true if the $a and $b have and only one is true, or False if all are true or false.
However, when testing the XOR operator, a little problem was founderror
When you operate in each expression, each part of the operation is evaluated in a certain order, which is the order of precedence of the operation, also called the precedence of the operator.
In an expression, if there is more than one operator,
Operator Precedence
When multiple operations are performed in an expression, each part is computed in a predetermined order called operator precedence. Parentheses can change the order of precedence, forcing a portion of the expression to be treated
The MySQL official documentation provides operators with the following precedence:Operator Precedences is shown in the following list, from highest precedence to the lowest. Operators that is shown together on a line has the the same precedence.1
The operands of predefined operators in C + + can only be basic data types, and in fact, for many user-defined types, similar operations are Required. For example:Class Complex{PublicComplex (double r=0.0,double i=0.0) {real=r;imag=i;}void Display ()
Priority level
Operator
Name or meaning
Use form
Combination direction
Description
1
[]
Array subscript
array name [constant expression]
Left to right
()
Parentheses
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 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.