Derived Types: Union

A union is similar to a struct, except it allows you to define variables that share storage space.

union [] {
} [] ;

union int_or_long {
int i;
long l;
} a_number;

Turbo C++ will allocate enough storage in a_number to accommodate the largest element in the union. Unlike a struct, the variables a_number.i and a_number.l occupy the same location in memory. Thus, writing into one will overwrite the other. Elements of a union are accessed in the same manner as a struct.