C ++ Primer 3 Reading Notes (1)

xiaoxiao2021-03-06  41

First part C overview

1. Object-oriented programming method extends the abstract data type by inheriting the Inheritance mechanism and dynamic binding Dynamic Binding mechanism, and the inheritance mechanism is reused for existing implementation code; dynamic binding refers to reuse of existing public interfaces.

2. C is a language that supports multiple programming methods, although we mainly regard it as an object-oriented language, but in fact it also provides support for processization and object-based programming methods, The benefit is that each problem can provide the most appropriate solution.

The first chapter begins

1. Separate Divide and Conquer and gradually refine STEPWISE REFINEMENT

2. Once the error is corrected, it should be recompiled immediately, which is often referred to as editing a editing of one-purpose debugging Edit Compile Debug.

3. Compiling C programs The compiler automatically defines a preprocessor name __cplusplus Note that there are two underscores in front. When compiling standard C, the compiler will automatically define the name __stdc__ Of course __cplusplus and __stdc__ will not be defined at the same time

4. The other two more useful predefined names are __line__ and __file __, __ line__ record files have been compiled, __ file__ contains the name of file being compiled

Chapter 2 C Views

1. C does not support the abstract Abstraction of arrays, nor does it support operations for the entire array

2. Objects can be static allocate - that is, the compiler is allocated at the time of handling the program source code; or dynamic allocation - that is, the runtime library function is called when the program is executed. The main difference between these two memory allocation methods is different from the balance criteria between efficiency and flexibility.

3. Two main differences between static and dynamic memory allocation: It is a static object being a variable of the name, and we do it directly; and the dynamic object is a variable without the name. We operate it indirectly through the pointer. Static object The allocation and release is automatically handled by the compiler; the allocation and release of the dynamic object must be explicitly managed by the programmer.

4. Memory leakage refers to a dynamically allocated memory. We no longer have a pointer to this memory so we have no way to return it to the program.

5. The constructor and the destructor are the functions provided by programmers, which neither constructs objects that are not destroyed, and the compiler automatically acts on these objects. The constructor of the class is mainly used to initialize the data of the class object, and the destructor is responsible for the release of all the resources applied in the life period.

6. In order to make a second design of a class into base categories to find the type-related member function and mark these member functions as Virtual virtual, for type-related member functions It is a specific basis Class or derived behavior or implementation

7. For a non-virtual function call, the compiler selects the called function at compile time; and the determination of the virtual function call should wait until each call point of the execution program inside the execution program, the system is based on the actual actual situation of the called object. The base class or derived class is determined which virtual function instance is selected.

8. Name Space Alias ​​Namespace Alias ​​allows an alternative short or more general name to associate with an existing name space, for example, // provides a more general alias

Namespace lib = IBM_CANADA_LABORATORY;

Use: lib :: array ia (1024);

In the standard C ammeter group, the C standard library is part of the C standard library, and now it is not called array, and the vector vector, of course, vector is a class.

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

New Post(0)