fork download
  1. #include <iostream>
  2.  
  3. struct A {
  4.  
  5. int x;
  6. int y;
  7. };
  8.  
  9. struct B : private A {
  10.  
  11. using A::x;
  12.  
  13. };
  14.  
  15. int main() {
  16.  
  17. B b;
  18. std::cout << b.x << std::endl;
  19. std::cout << b.y << std::endl; // should fail
  20.  
  21. }
  22.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:6:6: error: 'int A::y' is inaccessible
prog.cpp:19:17: error: within this context
stdout
Standard output is empty