fork download
  1. #include <iostream>
  2.  
  3. // .h
  4. class A {
  5. public:
  6. void load();
  7.  
  8. private:
  9. struct B {int i = 1;};
  10. };
  11.  
  12. // .cc
  13. void foo(A::B c) {
  14. std::cout << c.i << std::endl;
  15. std::cout << "YEAH!" << std::endl;
  16. }
  17.  
  18. void A::load() {
  19. foo(B());
  20. }
  21.  
  22. int main() {
  23. A a;
  24. a.load();
  25.  
  26. return 0;
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void foo(A::B)’:
prog.cpp:13:13: error: ‘struct A::B’ is private within this context
 void foo(A::B c) {
             ^
prog.cpp:9:10: note: declared private here
   struct B {int i = 1;};
          ^
stdout
Standard output is empty