fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Outer {
  5. class Inner {
  6. private:
  7. int x = 0;
  8. };
  9.  
  10. public:
  11. static void m() {
  12. Inner foo;
  13. cout << foo.x << endl;
  14. }
  15. };
  16.  
  17. int main() {
  18. Outer::m();
  19. return 0;
  20. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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;
           ^
stdout
Standard output is empty