#include #include using namespace std; //The function f can not change the value of its first argument, //but it could change the value of its second argument. void f(int i, int& r); int main() { int a {10}; int b {20}; f(a, b); //The function f increments b but not a. cout << "a == " << a << "\n" << "b == " << b << "\n"; return EXIT_SUCCESS; } //Demonstrate pass-by-value vs. pass-by-reference. //The initial value of i is a copy of the value of a. //But the value of r is always the same value as the value of b. void f(int i, int& r) { ++i; //Increments i, but this has no effect on the value of a. ++r; //increments b. cout << "i == " << i << "\n" << "r == " << r << "\n\n"; //Outputs the value of b. }