#include <iostream>
//function prototype or function definition
void funct1 (int);
void funct2 (int&); // & is needed to specify pass-by-reference
int main()
{
int var1;
var1 = 10;
cout << "Before the first function call, Var1 is: " << var1 << endl;
funct1(var1);
cout << "After the first function call, Var1 is: " << var1 << endl;
cout << "Before the second function call, Var1 is: " << var1 << endl;
funct2(var1);
cout << "After the second function call, Var1 is: " << var1 << endl;
}
// This function shows how a "pass-by-value" parameter works
void funct1 (int param1)
{
cout << "In the function, param1 is: " << param1 << endl;
param1++;
cout << "In the function, param1 is: " << param1 << endl;
}
// This function shows how a "pass-by-reference" parameter works
// The & before the parameter name indicates a pass-by-reference
// parameter.
void funct2 (int ¶m1)
{
cout << "In the function, param1 is: " << param1 << endl;
param1++;
cout << "In the function, param1 is: " << param1 << endl;
}