Show: Object Pascal C++
Display Preferences

union

From Appmethod Topics
Jump to: navigation, search

Go Up to Keywords, Alphabetical Listing Index


Category

Type Specifiers

Syntax

union [<union type name>] {
<type> <variable names> ;
  ...
} [<union variables>] ;

Description

Use unions to define variables that share storage space.

The compiler allocates enough storage in a_number to accommodate the largest element in the union.

Unlike a struct, the members of a union occupy the same location in memory. Writing into one overwrites all others.

Use the record selector (.) to access elements of a union .

See Also

Personal tools
In other languages