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 example

static 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;


About this entry