#include <iostream> using namespace std; void f(int &i); // i is a reference parameter int main() { int val = 1; cout << "Old value for val: " << val << '\n'; f(val); cout << "New value for val: " << val << '\n'; return 0; } void f(int &i) { i = 10; }
Old value for val: 1 New value for val: 10