RAD Studio |  |

Unions
Collapse All

This section contains Union topics.

Topics

Name | Description
Unions | Union types are derived types sharing many of the syntactic and functional features of structure types. The key difference is that a union allows only one of its members to be "active" at any one time. The size of a union is the size of its largest member. The value of only one of its members can be stored at any time. In the following simple case,
Anonymous Unions | A union that does not have a tag and is not used to declare a named object (or other type) is called an anonymous union. It has the following form:
Union Declarations | The general declaration syntax for unions is similar to that for structures. The differences are: Unions can contain bit fields, but only one can be active. They all start at the beginning of the union. (Note that, because bit fields are machine dependent, they can pose problems when writing portable code.) Unlike C++ structures, C++ union types cannot use the class access specifiers: public, private, and protected. All fields of a union are public. Unions can be initialized only through their first declared member:

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!