Reputation: 1434
Below is code was from C code, you could use bare word B1 B2 B3 directly. However in C++ it's not allowd, proper namespace is needed, How could I use B1 B2 B3 in C++ way then(what is the correct namespace for B1 B2 B3)?
struct A {
int X;
union {
struct B {
enum { B1, B2, B3 } ABCD;
}v2;
} v;
};
Upvotes: 0
Views: 48
Reputation: 10998
You can make an instance of the struct and access the members:
A a;
cout << a.v.v2.B1 << a.v.v2.B2 << a.v.v2.B3 << '\n';
Upvotes: 1