8. Structures, Unions, and Enumerations
Form a more perfect Union.
– The people
struct Layout; struct Names; Structures and Classes; Structures and Arrays; Type Equivalence; Plain Old Data; Fields
• Unions
Unions and Classes; Anonymous unions
enum classes; Plain enums; Unnamed enums
• Advice
8.1. Introduction
The key to effective use of C++ is the definition and use of user-defined types. This chapter introduces the three most primitive variants of the notion of a user-defined type:
• A struct (a structure) is a sequence of elements (called members) of arbitrary types.
• A union is a struct that holds the value of just one of its elements at any one time.
• An enum (an enumeration) is a type with a ...
Get The C++ Programming Language, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.