return value
C + + Specifies that the return value cannot be an array. But it can be any other type (including structs and objects).
Typically, the function copies the return value to the specified CPU register or memory cell, and then calls the function to call the value of the memory cell.
Function prototypes
Variable names can be excluded from the argument list, and variable names in the prototype are equivalent to placeholders, and do not need to be the same as in a function definition.
In C + +, NULL in the prototype () means no parameters, (...). ) means that the prototype does not specify a parameter list, and the parameter list is defined after the prototype.
Typically, the prototype automatically casts the passed argument to the desired type, provided that both are arithmetic types.
function parameters
When declaring multiple arguments, you cannot combine declarations like declaring variables, such as: float A, b; It is possible to declare a variable, but void function (float a, b) is illegal and should be
void function (float A, float b).
Function Pass Array
1 void int int length);
Where array is the address of the first element of the incoming array, this is beneficial: saving time and memory for copying the entire array. There are also disadvantages: there is a risk of destroying the original data.
Also, when passing an array, the length of the array needs to be passed separately, and the length of the pointer variable will be obtained using sizeof (array) in the function.
To prevent changes to the original data, you can precede the parameter with the const keyword.
1 void Const int int length);
The raw data is not necessarily constant, but for function, the raw data is read-only.
C + + supplements (vi) function-related