Structures, Classes, and Unions

The three class types are structure, class, and union. They are declared using the struct, class, and union keywords (see class-key syntax). Table 8.1 shows the differences among the three class types.

Table 8.1   Access Control and Constraints of Structures, Classes, and Unions

Structures Classes Unions
class-key is struct class-key is class class-key is union
Default access is public Default access is private Default access is public
No usage constraints No usage constraints Use only one member at a time