fork download
  1. union A
  2. {
  3. private:
  4. int a;
  5. int k;
  6.  
  7. void doSomething(){}
  8.  
  9. };
  10.  
  11. int main()
  12. {
  13. A obj;
  14. int i = obj.a;
  15. obj.doSomething();
  16. return 0;
  17. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:4: error: ‘int A::a’ is private
prog.cpp:14: error: within this context
prog.cpp:7: error: ‘void A::doSomething()’ is private
prog.cpp:15: error: within this context
prog.cpp:14: warning: unused variable ‘i’
stdout

Standard output is empty