After a few days of learning began to gradually touch the relative importance of C + + parts.
1, inline functions and function overloading
inline function: +inline before function
When this function is used, the code is embedded directly into the current position, mainly to avoid the function taking too much time in the process of calling the function.
Therefore, the inline function should be: 1, short, 2, often called. So that we can realize the value
Functions are overloaded, and functions are loaded automatically based on the invocation, mainly for functions with the same function name.
Note how you can make a function overload.
2. Basic design principle of function
This is more about methodology, and more practice in practice.
1, the function declares the design principle, mainly regarding the name, the entry parameter, returns the argument. This is basically a note.
2. The body design of the function
1. In the "entrance" of the function body, the validity of the parameters is checked 2, the function return value 1 is handled cautiously. The function should be clear and 12. The code of the function should be short and lean 3. The function should avoid nesting levels too many 4. function should avoid repeating code
9.8 C + + Learning Summary 2