#include <iostream> using namespace std; int main() { int value = 10; struct A { int f() { return value; } }; A a; cout << a.f() << endl; return 0; }
Standard input is empty
prog.cpp: In member function ‘int main()::A::f()’: prog.cpp:7:20: error: use of local variable with automatic storage from containing function int f() { return value; } ^~~~~ prog.cpp:5:6: note: ‘int value’ declared here int value = 10; ^~~~~
Standard output is empty