Can any one tell me the exact diff between call by pointer and call by reference. Actually what is happening on both case?
Eg:
Call By Reference:
void swap(int &x, int &y) { int temp; temp = x; /* save the value at address x */ x = y; /* put y into x */ y = temp; /* put x into y */ return; } swap(a, b); Call By Pointer:
void swap(int *x, int *y) { int temp; temp = *x; /* save the value at address x */ *x = *y; /* put y into x */ *y = temp; /* put x into y */ return; } swap(&a, &b);