#include #include using namespace std; int & Foo(int &); //int & Bar(int); int main() { int a{99}; // must initialize when declared. int &b{a}; cout << "After Initialization " << endl; cout << " a = " << a << endl; cout << " b = " << b << endl; cout << " &a = " << &a << endl; cout << " &b = " << &b << endl; cout << endl << endl; cout << "Setting b to be -100 " << endl; b = -100; cout << " a = " << a << endl; cout << " b = " << b << endl; cout << endl << endl; cout << "Setting a to be 42 " << endl; a = 42; cout << " a = " << a << endl; cout << " b = " << b << endl; cout << endl << endl; int & works = Foo(a); cout << "Works is " << works << endl; cout << " &a = " << &a << endl; cout << " &works = " << &works << endl; /* cout << "We will now have a bug " << endl; int & bad = Bar(3); cout << "Bad holds " << bad << endl; */ return 0; } int & Foo(int & x){ return x ; } /* int & Bar(int x){ int y{x}; return y ; } */