/** * @file scopes.cpp * @author Jeffrey Bergamini for CS 19 Boot Camp, jeffrey.bergamini@cabrillo.edu * * Let's see how much you understand/remember about scope and lifetime in C++! */ #include int x; void f1() { x = 2; std::cout << x << '\n'; } void f2(int x) { std::cout << x << '\n'; { int x; x = 4; std::cout << x << '\n'; } x = 5; std::cout << x << '\n'; } int main() { x = 1; std::cout << x << '\n'; f1(); std::cout << x << '\n'; f2(3); std::cout << x << '\n'; int x; x = 6; std::cout << x << '\n'; }