Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The next programmer-defined aggregate data types on our agenda are structures. C++ structures are a powerful aggregation tool for combining related components. There is more than one method to define a structure in C++, and we will discuss the most popular ones. All methods allow the programmer to define structure components (fields, or data members), that is, to list the types and names of the components.
The structure definition starts with the keyword struct followed by the programmer-defined name that will be used as a type name to define variables in the program. The structure fields are declared within scope curly braces followed by a semicolon. Each field declaration is similar to a declaration of a variable: It includes the type and the programmer-defined name but cannot include initialization.