fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A {
  5. public:
  6. int a;
  7. };
  8. class B : A {};
  9.  
  10. int main() {
  11. B item;
  12. item.a = 5;
  13. return 0;
  14. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:12:7: error: ‘int A::a’ is inaccessible within this context
  item.a = 5;
       ^
prog.cpp:6:6: note: declared here
  int a;
      ^
stdout
Standard output is empty