"C ++ Primer Third Edition" Reading Notes - Chapter 4 Expression

zhaozj2021-02-16  68

1, PTR! = 0 && * PTR! = 0 and PTR && * PTR, the latter is more conforming to C program habits.

2, the calculation of the expression refers to performing one or more operations, and finally generates a result, typically a right value, the result is determined by the type of operand.

3. For composite expressions, starting from the left, the sub-expression behind the first capable result is not calculated.

4. If there is one (or two) in the two operands to be negative, the symbols of the results of the mold (%) depend on the machine, and the transplantability cannot be guaranteed.

5. The calculation of the calculation expression causes an incorrect or undefined value, ie the calculation exception (but does not throw the actual exception). The calculation abnormality is attributed to the natural nature of the calculation (such as 0) or the natural nature of the computer (such as overflow).

6. The calculation order of the operand of the binary relationship operator is undefined in standard C or C , so the calculation process must be independent of the order, such as:

IF (IA [Index ]

7, SIZEOF's three forms:

Sizeof (Type Name) Sizeof (Object) Sizeof Object

The return value type is size_t, is a type of TypeDef, which requires the header file.

#include

8, SIZEOF is calculated at compile time, is considered a constant expression.

9. The system provides each program with a memory pool available in the program execution, which is used as an idle storage area or a heap.

10, New:

INT * pi = new int; // or directly initialize int * pi = new int (1024); int * PIA = new int [10];

Corresponding delete:

Delete Pi; delete [] PIA;

11. The comma expression is calculated from left to right and the value of the rightmost expression at the time.

12. In most bits, the processing of symbol bits is undefined, so it is strongly recommended to use unsigned types.

13. General guidance principles for arithmetic conversion:

To prevent accuracy loss, the type is always enhanced into a wide type if necessary. All calculation expressions containing integrity types are converted to integer.

14. By using the forced type conversion operator, the programmer turns off the type check facility of the C language.

15. Const_cast must be applied to a constant object and convert the expression of the expression (and the Volatile property of the Volatile object).

16, static_cast is used for all types of implicit conversions, displayed.

17. ReinterPret_cast usually performs a relatively low-level center interpretation for bit mode of the operand, such as:

Complex

* PCOM;

Char * pc = reinterpret_cast (pcom); // What is the PC? How does it explain to the memory of the PCOM? Halo ~

18. Two forms of old-style forced type conversion:

TYPE (EXPR); (TYPE) EXPR;

Can be used instead of Static_cast, const_cast, reinterpret_cast in standard C . But it is recommended to use display conversion.

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

New Post(0)