unsigned

union

A union is a special type of class that assigns two or more variables to the same memory location. The form of its definition and the way the . (dot)
and –> (arrow) operators reference a member are the same as for a class. By default, a union’s members are public. The general form is

 union class-name {     // public members by default private:     // private members } object-list; 

The class-name is the type name for the union.

NOTE: In C, unions can contain only data members and the private specifier is not allowed.

For example, this creates a union between a double and a character string and creates one variable called my_var.

union my_union {   char time[30];   double offset; } my_var;

The union is covered in more detail in Chapter 1.




C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net