Forward Declarations for Enumerations
Under the new standard, we can forward declare an enum
. An enum
forward declaration must specify (implicitly or explicitly) the underlying size of the enum
:
// forward declaration of unscoped enum named intValuesenum intValues : unsigned long long; // unscoped, must specify a typeenum class open_modes; // scoped enums can use int by default
Because there is no default size for an unscoped enum
, every declaration must include the size of that enum
. We can declare a scoped enum
without specifying a size, in which case the size is implicitly defined as int
.
As with any declaration, all the declarations and ...
Get C++ Primer, Fifth 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.