keywords:union

C++ Reference

union

Syntax:

    union union-name {
    public-members-list;
    private:
    private-members-list;
    } object-list;

A union is like a class, except that all members of a union share the same memory location and are by default public rather than private. For example:

     union Data {
       int i;
       char c;
     };

Related Topics: class, struct