C++ Programming - Global Anonymous Unions
An anonymous union that is declared in a named namespace or in the global namespace has to be explicitly declared static. For examplestatic union //anonymous union in global namespace
{
int num;
char *pc;
};
namespace NS
{
static union { double d; bool b;}; //anonymous union in a named namespace
}
int main()
{
NS::d = 0.0;
num = 5;
pc = "str";
return 0;
}
Labels: C++
About this entry
You’re currently reading “
- Published:
- 1:33 am
- by -
0 Comments (Post a Comment)