Questions about the transfer function
Users questions: Parameter in the definition is that: Exchg1 (int * x, int * y); pass by reference in this context is that: Exchg1 (int & x, int & y); want to know what is the difference between? ? ? ? What is the definition parameters, type
Experts answer: passed by reference is passed Address, and the value passed is the parameter value passed Exchg1 (int * x, int * y); parameter is an integer pointer, the pointer is passed in the address pointed to, but not the pointer address within the function called when the will modify the original pointer address value, but can not modify this One of the original pointer address. Such as: int * a, * b, c, d; a = &c; b = &d; Exchg1 (a, b);, in this code, the function can only modify the c, d values, but can not modify a, b values. Exchg1 (int & x, int & y); Participation Number is an integer variable, the variable passed in the two addresses, so modified in the function x, y values, will change the value of the original variables, such as: inta, b; a = b = 0; Exchg1 (a, b );, changes in the function x, y value will change a, b values