union A { private: int a; int k; void doSomething(){} }; int main() { A obj; int i = obj.a; obj.doSomething(); return 0; }
Standard input is empty
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’
Standard output is empty