#include <iostream> using namespace std; class Outer { class Inner { private: int x = 0; }; public: static void m() { Inner foo; cout << foo.x << endl; } }; int main() { Outer::m(); return 0; }
Standard input is empty
prog.cpp: In static member function ‘static void Outer::m()’: prog.cpp:13:15: error: ‘int Outer::Inner::x’ is private within this context cout << foo.x << endl; ^ prog.cpp:7:11: note: declared private here int x = 0; ^
Standard output is empty