Objects of union type are initialized with a single value (if the union does not have a constructor). This is done in one of two ways:
struct Point
{
unsigned x;
unsigned y;
};
union PtLong
{
long l;
Point pt;
};
...
PtLong ptOrigin;
PtLong ptCurrent = ptOrigin;
In the preceding code, ptCurrent
is initialized with the value of ptOrigin
— an object of the same type.
PtLong ptCurrent = { 0x0a000aL };