"Primer C ++ 3RD" reading note 1

xiaoxiao2021-03-06  69

The first chapter and the second chapter have been read before, where it is more likely to be forgotten here. Total two chapters are introduced in nature.

Chapter One

General way to solve problems: Separately seek and gradually refine Divide and Conquer and Stepwise Refinement. Sometimes the steps and reality of the analysis have different steps, which is mainly due to the conditions of the virtual space in the computer. The steps are both an algorithm.

Function Series consists of four parts: return type, function name, variable table, function body. The first three syndrome is called a function. When you declare the function, you must write a function when the function is defined.

The program has the main () function starts, and the content is performed item-by-item until the return () function in main () is encountered. Return () is a C predefined function that is aborted when the function is encountered. In the C standard, if the return statement is provided in main (), its default return value is 0.

In the pretreatment command, when the header file is included, <> The header to which you want to include is a project or the header file in the standard library, and the compiler will find this file in the defined directory; "" means that you want to include a user The header provided, the compiler will first look for the current file directory.

Since the header file can be used nested, in order to prevent repeated load files, the following statement is usually added in the defined header file: #ifndef bookstore_h # define bookstore_h / * bookstore.h contents go here * / # ENDIF these statements are The pretreatment constant of the two header files can be used to use this Strategy Works Well Provided That No Two Header Files Necessary for Inclusion Test ON A Preprocessor Constant Of The Same Name, so pay attention to the selection of the pre-processes such as BookStore_h. Uniqueness.

When compiling, the pre-processor constant can be defined by the command line in the compiler, and selective compilation is completed externally.

When compiling C programs, the compiler will automatically join the __cplusplus (TWo underscores) preprocessor name; and add the __stdc__ predecessor name in the C code.

The compiler also joins the number of __line__ currently compiled, __ file__ The currently compiled file name, __ Time__ format: hh: mm: s, __DATE__ format: Month (English abbreviation) Japan.

These compilers can be used in the program, such as #ifDef __cplusplus // // ok: We're Compiling C // We'll Explain Extern "C" in Chapter 7! EXTERN "C" #ENDIF INT MIN (int, int); and if (element_count == 0) CERR << "Error:" << __file__ << ": line" << __line__ << "Element_Count Must Be Non- ZERO./N";

Assert.h is very large, using Cassert in C standards.

/*...*/ Notes cannot be nested. If necessary, you can add space between internal / * to solve it.

Note this paragraph: #include #include #include int main () {OFStream outfile; ifstream infile ("in_file"); if (! Infile) {CERR << " Error: unable to open input file! / n "; return -1;} if (! outfile) {cerr <<" error: unable to open output file! / n "; return -2;} String Word; While (Infile >> Word) Outfile << Word << ''; return 0;} 1, FStream itself contains iostream, which is repeated, but because there is a previous pretreatment condition, there will be no problem. 2. Implement the end () through the return and condition statement, a total of multiple returnes, but only one Return is only one RETURN. 3, infile, outfile is an object. If the read file is successful, it is not zero, if (! "Can be used to determine if the read file is successful.

The other content of this chapter will be expanded behind the chapter, so there is not much written here.

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

New Post(0)