#include <iostream> auto f(int x) { class Unnameable { public: int getval() { return x; } }; return Unnameable();} int main() { auto var = f(125); using voldemor_t = decltype(var); int x = 56; auto harbinger = new voldemor_t(); std::cerr << harbinger->getval() << "\n"; return 0;}
Standard input is empty
prog.cpp: In member function 'int f(int)::Unnameable::getval()': prog.cpp:6:30: error: use of parameter from containing function int getval() { return x; } ^ prog.cpp:3:12: note: 'int x' declared here auto f(int x) { ^
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!