struct Base { int a; }; union TestFails{ struct A : public Base {}; int b;}; union TestWorks{ struct A { int a; }; int b;}; int main(){ TestWorks works; works.a = 0; TestFails fails; fails.a = 0; return 0;}
Standard input is empty
prog.cpp: In function 'int main()': prog.cpp:20:8: error: 'union TestWorks' has no member named 'a' works.a = 0; ^ prog.cpp:23:8: error: 'union TestFails' has no member named 'a' fails.a = 0; ^
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!