blob: 1f9944b8786ed2406347ab3fc000914375b407f3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#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";
int &z = x;
f(z);
std::cout << "x = " << x << "\n";
std::cout << "z = " << z << "\n";
int &u = z;
f(u);
std::cout << "x = " << x << "\n";
std::cout << "z = " << z << "\n";
std::cout << "u = " << u << "\n";
f(z);
std::cout << "x = " << x << "\n";
std::cout << "z = " << z << "\n";
std::cout << "u = " << u << "\n";
f(x);
std::cout << "x = " << x << "\n";
std::cout << "z = " << z << "\n";
std::cout << "u = " << u << "\n";
}
|