#include // Sample program to show the difference between reference // and value parameters. void happy(int k); // value ==> won't affect calling arg void joy(int& j); // reference ==> might affect calling arg main() { int x=1; cout << "First with happy:\n"; cout << " BEFORE: x = " << x << endl; happy(x); cout << " AFTER: x = " << x << endl; cout << "Now with joy:\n"; cout << " BEFORE: x = " << x << endl; joy(x); cout << " AFTER: x = " << x << endl; } void happy(int k) { k = 500; } void joy(int& j) { j = 500; }