After the problem of parameter delivery, I still think that the pointer and pass reference are one. What is the difference?
Since the pointer in C can reach the effect, do you have to be referenced?
Zhang Jun brother believes that the introduction of the concept of Reference in C makes the programming.
For example: swap ()
c pointer version
INT SWAP (INT * X, INT * Y) {INT TEMP; TEMP = * x; * x = * y; * Y = Temp; Return Temp;} void main () {Int a = 1, b = 2; int * p1 = & a; int * p2 = & b; swap (p1, p2)}
C reference version
INT & SWAP2 (INT & X, INT & Y) {INT TEMP; TEMP = X; X = Y; Y = Temp; Return X;}
Void main () {INT A = 1, B = 2; SWAP2 (A, B);
Although the address is actually treated in the reference, there are many *. There are many procedures when editing the program.
References Were IntrouseD Primarily To Support Operator Overloading .-- Bjarne Stroustrup, The Design and Evolution of C