Call-by-Reference
#include <iostream>
using namespace std;
void f(int &a, int &b)
{
a = a + 3;
b = b + 5;
}
main()
{
int x = 10;
int y = 25;
f(x,y);
cout << x << " " << y << endl;
x = 10;
f(x,x);
cout << x << endl;
}
Output is:
13 30
18
When the second call runs, both a and b are aliases for
x in the main.