Structs, Enums, and Type Aliases
Defining and Using Structures
A program rarely works with single numbers or single words; usually, related values have to stick together, and a structure makes it possible for the program to…
Passing and Returning Structures
Structures can be passed and returned from functions like any value type. When you pass a structure to a function, the object is actually copied. That function…
Enumerations
Often a program needs a handful of named options that are really just related integers. Hardcoding the integers makes the code unreadable and prone to errors. A…
Scoped Enumerations with enum class
Regular enumerations declare their names in the surrounding scope and automatically allow themselves to be converted to integers. In both of these cases, you ca…
Type Aliases with using
A type name repeated numerous times in a program can become quite a mouthful, and when the type needs to change, it can be even more of a nuisance. The purpose…