Parameter: "formal parameter" is a parameter used when defining the function name and function body. It is used to receive parameters sent when the function is called.
Real parameters: All called "actual parameters" are parameters that pass the function during the call.
The type of the form parameter and the real parameter must be the same, or the implicit conversion rule must be met,
When the form parameter and the real parameter are not of the pointer type
Parameters are different variables in different locations in the memory.
Copy the content of the parameter and release the parameter at the end of the function,
The real parameter content will not change.
If the function parameter is a pointer type variable
The real parameter address is used to pass a function.
The real parameter address, that is, the real parameter itself.
You can change the value of a real parameter.
Write a function that exchanges values a and B.
By value (C ++ ):
Function declaration: swap (x, y ){.....}
Function call: int a = 5; int B = 6;
Swap (a, B)
Note: Pass the values of a and B to x and y respectively. In fact, the value of a and B does not change. a and B are not successfully exchanged. Values of two numbers cannot be transferred by value.
Cout <a; // a = 5
Cout <a; // B = 6
Reference (C ++ ):
Function declaration: swap (& x, & y ){.....}
Function call: int a = 5; int B = 6;
Swap (a, B)
Note: Pass the values of a and B to x and y respectively. In fact, the value of a and B has not changed.
Cout <a; // a = 6
Cout <a; // B = 5
Pointer (C ++ ):
Function declaration: swap (* x, * y ){.....}
Function call: int * a = 5; int * B = 6;
Swap (a, B)
Note: Pass the values of a and B to x and y respectively. In fact, the value of a and B has not changed.
Cout <a; // a = 6
Cout <a; // B = 5
Author: ERDP Technical Architecture"