#include <iostream>usingnamespace std;
// Passing arrays by reference, and reference parameters.void f(int a[], int x, int& y) // & indicates a reference parameter
{
// Function can change either of its parameters,// but x is a VALUE parameter, so it doesn't affect// the value at the call site.
x++;
cout << x << "\n"; // 100// The array a is a REFERENCE parameter (because it's an array)// so changing it DOES affect the call site.
a[3]++;
cout << a[3] << "\n"; // 8
y++;
cout << y << "\n"; // 61
}
int main()
{
int b[5] = { 3, 4, 1, 7, 2 };
int x = 99;
int y = 60;
f(b, x, y);
cout << x << "\n"; // 99
cout << b[3] << "\n"; // 8
cout << y << "\n"; // 61//f(b, x, 24); // error, need a variable to point to
f(b, x, b[2]);
int k[2] = { 1, 2 };
f(k, x, y); // PROBLEM: k is too short, f accesses a[3]return0;
}