Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
int z = 4;
int& w = z;
auto w1 = z; //int
std::cout << z << " " << w << " " << w1 << "\n"; //4 4 4
w = 16;
std::cout << z << " " << w << " " << w1 << "\n"; //16 16 4
w1 = 256;
std::cout << z << " " << w << " " << w1 << "\n"; //16 16 256
auto& w2 = z; //int&
w2 = 65536;
std::cout << z << " " << w << " " << w2 << "\n"; //65536 65536 65536
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment