Chapter 6 Function: Enter parameters: Output parameters: Return Value: Assert is a macro that acts only on the debug version, which is used to check the situation that "should not" happen. Consider Return's efficiency, choose to use references or pointers, not values. The difference between the temporary object and the local object is used to use some of the rules that use the Static local variable reference: (1) Quote must be initialized while being created (the pointer can be initialized at any time). (2) There is no NULL reference, the reference must be associated with the legal storage unit (the pointer can be null). (3) Once the reference is initialized, the reference is not changed (the pointer can change the object you refer to time). The main function of the reference is to transfer the parameters and return values of the function. In the C language, there are three ways to pass the parameters and return values: value transfer, pointer delivery, and reference delivery. The nature of "reference delivery" is like "pointer", and writing the way "value transfer". In fact, anything "pointer" that can be done can also do, why should I "quote"? The answer is "Doing the right tool to work with appropriate tools."
Chapter 7 1, the memory allocation method: static storage area, stack area, pile zone 2, common memory error and countermeasure: memory allocation is unsuccessful, but use it - solution, check pointer before use Whether it is a NULL memory allocation, but it has not been initialized, it references it - a solution, be sure to initialize the memory allocation and have been initialized, but the operation exceeds the boundary of the memory - the solution, the half-open semi-closed interval Release memory, causing memory leakage released memory, but there are three situations [Rule 7-2-1] After using Malloc or New to apply for memory, you should immediately check if the pointer value is NULL. Prevent memory using the pointer value of NULL. [Rule 7-2-2] Don't forget to be a first value for array and dynamic. Prevent memory that will not be initialized as the right value. [Rule 7-2-3] Avoid the subsidiaries of array or pointer, especially "more than 1" or "less 1" operation occurs. [Rule 7-2-4] The application and release of dynamic memory must be paired to prevent memory leakage. [Rule 7-2-5] After using Free or Delete released memory, set the pointer to NULL to prevent "wild pointer". 3, the comparison of the pointer and array takes a string as an example, and the description: modify the content; compare memory replication and comparison; calculate memory capacity. 4. How the pointer parameters pass the memory, the pointer as the parameter and the pointer of the pointer as the difference in the function of the file, and the return value can also pass memory. 5, FREE and DELETE role, memory is released, but the pointer itself is not eliminated. It is necessary to assign NULL6, (1) The pointer is dying, and does not mean that the memory it is referred to will be released. (2) The memory is released, and does not mean that the pointer will die or become a NULL pointer. 7, eliminate the wild pointer - "wild pointer" is not a NULL pointer, pointing to the pointer to "garbage" memory. There are two main cations of "wild pointers": (1) The pointer variable is not initialized. (2) The pointer P is after free or delete, it is not set to NULL, making it mistaken to P is a legal pointer. (3) The pointer operation exceeds the scope of the variable. The wild pointer, the IF statement cannot identify this error. 8. Why is Malloc / Free to New / Delete, Malloc / Free cannot perform the task of constructor and a destructor. Cannot perform, initialize and clear work. 9. What should I do if my memory consumption? Three options: Exit function, exit program, exception handling, Win32 does not have internal deposits, because there is virtual memory technology 10, Malloc / free's use points, type conversion, and application space length 11, New / Delete's usage points New is simpler than Malloc, because NEW has built-in SIZEOF, type conversion, and type security check functions. Use of delete []. 12, some experience
Chapter 8 Member Functions are overloaded: (1) The same range (in the same class); (2) The function name is the same; (3) Virtual keywords can be available. The overlay is the specifier of the class function overlay base class function. The features are: (1) Different ranges (located in the derived class and base class); (2) The function name is the same; (3) The parameter must be There are virtual keywords. (1) If the derived class function is the same name, the parameters are different. At this point, the function of the base class will be hidden, whether there is a Virtual keyword, and not to confuse the overload. (2) If the derived class function is the same name, and the parameters are the same, the base class function does not have a Virtual keyword. At this point, the function of the base class is hidden (notes confusing with overlay).
The function inline mechanism of the C language has both the efficiency of macro code, but also the security of the information, and the data member of the class. Inline is a "keyword for implementation" instead of "keyword used to declare". There are three ways to use.
Chapter 9 A (Void); // Default-free parameter structure A (Const A & a); // Default copy constructor ~ A (void); // Default destructor A & Operate = Const a & a); // Default assignment function
The order of the initialization of the member object is completely unlikely the order of the order in the initialization form, only by the order of the member objects declared in the class. This is because the statement of the class is unique, and the class constructor can have multiple, so there will be a plurality of different order initialization tables. If the member object is constructed in the order of the initialization table, this will cause the destructuring function that cannot be unique.