blob: 1f9944b8786ed2406347ab3fc000914375b407f3 (
plain) (
tree)
|
|
#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";
}
|