1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream> void f(int &y) { y = y + 1; } int main() { int x = 41; std::cout << "x = " << x << "\n"; f(x); std::cout << "x = " << x << "\n"; f(x); std::cout << "x = " << x << "\n"; x = 0; std::cout << "x = " << x << "\n"; f(x); std::cout << "x = " << x << "\n"; }