C ++ overload, pointer, and reference
C ++ overload/pointer/reference 1. Overload
Function names are the same and parameters are different (type and quantity ). Different return values cannot be overloaded.
As follows:
int add(int a, int b){ cout<<"add int+int"<
2. pointer
Same as C Language
3. Reference 3.1. What is reference
Referencing is the alias of an object, which is the same as a person's name: there is a name on the ID card, and others can give you multiple small names that are frequently used in daily life.
3.2. The referenced Representation Method
The expression of the definition reference is similar to the definition pointer, but it is replaced *.The reference is just an object alias and does not allocate memory space separately.The referenced operation is the same as the variable operation. The format is: Type & reference variable name = variable names that have been defined.
3.3 references
A. It must be initialized during the Declaration and cannot be changed later.
B. You cannot create an array reference. Because an array is a collection composed of several elements, you cannot create an array alias.
C. Find the address of the reference, that is, find the address of the target variable.
Example 1:
Int I = 5; int j = 6; int & k = I; k = j; // The values of k and I are changed to 6;
Example 2: Reference Transfer
Void Swap (int & left, int & right) // if a reference is used, no temporary copy is made. & the usage instructions here are just another name of the original parameter, therefore, the variable value is directly modified based on the original parameter. {Int temp = left; right = left; left = temp ;}