C ++ Primer Learning Notes (4) - Expression

xiaoxiao2021-03-06  41

Chapter 4: Expression

1. In practice, the order of calculation of sub-expression is usually the root cause of beginners, so when you can't remember the calculation order of some operators, the plug is clearly specified in the calculation order.

2. As long as the value of the value of the expression is true, the true or false calculation will end, given the following form

EXPR1 && EXPR2

EXPR1 || EXPR2

If the following conditions have a satisfaction

The calculation result of Expr1 in logic and expression is false

The calculation result of Expr1 in logic or expression is true

Then guarantee that EXPR2 is not calculated

3. Common expressions are a range of expressions separated by commas that calculate from left to right, and the result of comma expression is the value of the rightmost expression.

4. The priority and conjunction of the operator (of course you can also check the book, but since you can't remember, I think most of them can't remember), such as the first point, add parentheses to clearly calculate order.

5. Type conversion:

l Implicit Type Rotation: C Defines the standard conversion between a set of built-in type objects to be implicitly applied to the object when necessary.

l Arithmetic conversion: Arithmetic conversion ensures that the two operands of the binary operator such as addition or multiplication are promoted to a common type, and then use it to represent the result. The two general guidelines are as follows:

1 To prevent precision, if necessary, the type of words is always enhanced into a wide type

2 All arithmetic expressions containing less than integer types are converted to integer.

l Show conversion: Mandatory Type Transformation (CAST)

转载请注明原文地址:https://www.9cbs.com/read-53717.html

New Post(0)