fork download
  1. struct S {
  2. public:
  3. int x;
  4. };
  5.  
  6. class C : S {};
  7.  
  8. int main() {
  9. C c;
  10. c.x; // Inaccessible, since C is declared with the class keyword,
  11. // even though S was declared with the struct keyword.
  12. return 0;
  13. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:3:6: error: 'int S::x' is inaccessible
  int x;
      ^
prog.cpp:10:4: error: within this context
  c.x; // Inaccessible, since C is declared with the class keyword,
    ^
stdout
Standard output is empty