- Union names form a separate namespace
struct UNION {
member1type member1;
member2type member2;
};
usage in declarations and definitions requires keyword
union
in C (recommended to C++ too)
union UNION u;
typedef
can be used to shorten
declarations and definitions
typedef union UNION Union;
Union u;
typedef
and union
declarations can be combined into one construct
typedef union UNION {
member1type member1;
member2type member2;
} Union;
- Typically, inner
union
declaration
needs no name
typedef union {
member1type member1;
member2type member2;
} Union;