Описание тега unions
The plural of a keyword in the C family of languages for declaring a union data type.
A union is a single variable with multiple possible representations. For example:
union foo {
int a;
float b;
struct {
char c, d;
} e;
};
is a variable foo
that can be accessed as either an int
, float
, or struct
. Although similar in format to a struct
, the size of a union is equal to the size of the largest field where as the size of a structure is the sum of the sizes of all fields.
They can also be used for a primitive form of polymorphism. A program can check for types and use different fields in a union in different contexts.
For the SQL UNION
keyword, use union instead of this tag.