fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A
  5. {
  6. int x;
  7. };
  8.  
  9. class B : A
  10. {
  11. public:
  12. int foo()
  13. {
  14. return x;
  15. }
  16. };
  17.  
  18.  
  19. int main() {
  20. B b;
  21.  
  22. cout << b.foo() << endl;
  23.  
  24. b.x = 1;
  25.  
  26. return 0;
  27. }
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::x’ is inaccessible
  int x;
      ^
prog.cpp:24:4: error: within this context
  b.x = 1;
    ^
stdout
Standard output is empty