1. The function is static when it is not called, and the form parameter is only a symbol. The function is executed only when it is called. It is also called before the main function assigns the real parameter to the form parameter.
2. function call Execution Process: when a program is started, the code is first loaded to the code area of the memory from the external memory, and then executed from the entry address (the start address of the main function. During the execution of the program, if other functions are called, the execution of the current function is suspended first. Save the address of the next instruction as the return address and save the field, go to the subfunction entry address and execute the subfunction. After the sub-function is executed, return to the main function, restore the site, and continue the execution from the previously saved instruction address.
3. function parameter transfer: refers to the process of combining the form parameter with the real parameter. There are two methods: Value call and Reference call.
4. Value call: When a function call occurs, allocate the memory space for the form parameter, initialize the form parameter with the real parameter, and directly pass the value of the real parameter to the form parameter. This process is a one-way transfer process of parameter values. subsequent changes in the form parameters do not affect the real parameters.
5. Reference call: A reference is a special type of variable that can be considered as an alias for another variable. The effect of accessing a variable through the referenced name is the same as that of the referenced variable name.
Example:
Int I, j:
Int & ri = I; // create an int type reference and initialize it as an alias of the variable I
J = 10;
Ri = j; // equivalent to I = j;
When using a reference, you must note that a reference must be initialized to point to an existing object.
B. Once a reference is initialized, it cannot point to other objects.
When a function is called, the reference is used as an alias for the real parameter. Any operation on the parameter is an operation on the real parameter.
6. inline functions: instead of controlling the transfer during a call, the function body is embedded into each call during compilation.
Inline void Func ();
Notes about inline functions: inline functions must be simple functions, small-sized functions that are frequently used, and cannot contain statements such as loops and switches.
Inline functions must be defined before they are used for the first time.
An exception interface cannot be declared for inline functions.
The compiler does not guarantee that the inline identifier function must be used as an inline function.
7. Default Parameter Function: ensure that no non-default parameter is behind the default parameter. When a function is called, the initialization sequence of the real parameter is from left to right.
8. function overload: Two or more functions have the same function name, but the number or type of the form parameter is different. The compiler will best match the type and number of the real parameter and the form parameter, automatically determines which function to call. This is the function overload.