"C ++ Primer Third Edition" Reading Notes - Chapter 5 Statement

zhaozj2021-02-16  80

1. For the definition of the class object, the locality of the declaration becomes necessary due to the definition of the class object. The reason why C does not encourage the definition of all objects in the top of the block, encouraging local statements because:

Make the program easier to read. Performance effects.

The constructor of all class objects will be called before doing anything in the block. The locality of the declaration makes the initialization overhead are shared. If all the definitions of the object is placed on top of the block, the block will end properly when it is not used to these objects, then unnecessary constructor - the overhead of the designer pair.

2, in C , the empty housing ELSE error is resolved by the specified: the ELSE clause matches "the last unqualified IF clause".

3. After the keyword case, it must be an integer type constant expression, and any two CASE tags cannot have the same value.

4, isalpha () is a routine of the standard C library: Returns true if its parameters are an English letter. Requires header file

#include

5. Place a statement statement in the statement associated with CASE or Default, unless it is placed in a statement block, such as

Case OK; {// do something}

6, in the format

For (Init-Statement; Condition; Expression) Statement

In, init-statement can define multiple objects, but only one declarative statement can appear, so objects are the same type.

7. Before standard C , the visibility of the object defined in Init-Statement can be extended to the statement block contained in the FOR loop, but the visibility of this object is only within the FOR cycle in standard C .

8, in

Do StatementWhile (Condition);

Object definitions are not supported in Condition.

9. Break can only appear in a loop and switch-case statement, and Continue can only appear in a loop statement.

10. GOTO statements can only jump to a location inside the same function. Reference numerals (Label, Goto's goals) cannot be followed in front of right brackets. Can't skip the statement that is not surrounded by the statement block forward, such as

INTOPPS_IN_ERROR () {// Mumble ... goto end; // error: Skip declaration statement int = 10; // ... code using ixnd:;

The correct one should be

INT OPPS_IN_ERROR () {// Mumble ... goto end; {// ok: declared statement int = 10 in statement blocks; // ... code using ix} end:;

This is the need for the compiler to insert the constructor - destructive function call for class objects.

11, Abort (), terminate program, header file:

#include

Description (MSDN):

The abort function, also declared in the standard include file STDLIB.H, terminates a C program. The difference between exit and abort is that exit allows the C run-time termination processing to take place (global object destructors will be called), whereas Abort Terminates the program immediately.12, "Do not give users a function" than "to provide an incorrect function that causes user programs to die."

13. Keyword TypenAme and Class can be interchangeable, Typename is newly introduced in standard C .

14. Basic components of standard C programming for templates

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

New Post(0)