reference function in c++
// function definition to swap the values. 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; }
Source: www.tutorialspoint.com
REFERENCE C++
int& r = i;
Source: www.tutorialspoint.com
c++ reference
int x = 5; int &y = x; cout << "The value of x is " << x << endl; cout << "The value of y is " << y << endl; y++; cout << "The value of x is " << x << endl; cout << "The value of y is " << y << endl;