// illustrates difference between call-by-value and by-reference // Walter Savitch // 10/3/00 #include using std::cout; using std::endl; using std::cin; // one is call-by-value, two is call-by-reference void doStuff(int one, int &two); int main(){ int n1=1, n2=2; cout << "n1 before function call = " << n1 << endl; cout << "n2 before function call = " << n2 << endl; doStuff(n1, n2); cout << "n1 after function call = " << n1 << endl; cout << "n2 after function call = " << n2 << endl; } void doStuff(int one, int &two) { one = 111; cout << "one in function call = " << one << endl; two = 222; cout << "two in function call = " << two << endl; }