"1" concept
function functions, each of which is used to implement a particular function.
"2" function declaration and definition
A declaration indicates that the function exists, and the definition indicates how the function is to run;
" the function declaration is to inform the compiling system of the information about the function (function name, functions type, function argument list) and check it at the call . "
"Function definition is the determination of function function, is a complete, independent unit of function"
Declaring the function to be called at the beginning of the file (outside of the function), the compiled system has already learned the information about the function from the external declaration, so it is not necessary to repeat the declaration in the main function.
"3" function call
When declaring a function, the parameter has no actual value, but it acts as a placeholder, called the formal parameter.
When invoking a function, the parameter must be a deterministic value, which is the real parameter that can actually work on the result.
During a call to a function, the system passes the value of the argument to the parameter of the called function, which is valid in the function call device and can participate in the operation of the function.
An argument can be a constant, a variable, or an expression; max (3,a+b);
When a function call is executed, the value of the parameter changes, but does not change the argument value of the keynote function. "The data passing of an argument to a parameter is a" value pass ", one-way pass, which can only be passed by an argument to a parameter argument and the formal parameter occupies a different storage unit in memory, and the argument cannot get the value of the parameter. 】
The compilation system only cares about and examines the number of parameters and parameter types, not the parameter names, because the argument types and formal parameter types are guaranteed to be consistent in the invocation process, regardless of the formal parameter name. Therefore, the formal parameter names can be written in the function declaration is not writable;
Returns the statement return
1) The value of the expression is fed to the calling function where the result of the function is run.
2) End the run of the function, return to the place where the function is called, and proceed to the following statement. "If a return is executed, the following statement is no longer executed"
"4" function overload
A function that has the same function is integrated into a function without having to write multiple functions with different function names, and multiple functions share a functional name .
"5" Reference
References (Referencen)
Variable data type & reference name = declared variable name;
When you use a reference to a variable, the action on the reference is like the action on the referenced variable. When declaring a variable, you must tell the computer which variable is referenced.
Using reference to pass parameters, using reference to return;
"6" Value as function parameter
Call the parameter function, need to provide an argument;
Array elements are equivalent to variables, where variables can occur, and can be replaced with array elements.
The array name can be used as an argument and a formal parameter, passing the address of the first element of the array;
The real parameter group and the shape parameter group type should be consistent.
The shape parameter group can not specify the size, when the array is defined with an empty square bracket after the array name;
3, Function--Modular design