January 2011
Intermediate to advanced
1648 pages
70h 30m
English
Because we’ve mentioned the word constant quite a bit, you might be wondering where enum members get their values. Moreover, what’s the type of those constant values? To answer those questions, we must introduce the notion of an underlying type that’s associated with an enum’s definition. The underlying type indicates the domain for the constants declared within the enum. If left unspecified, an enum’s underlying type is a 32-bit integer. You can specify the underlying type explicitly as shown here:

You’ll see this colon “derives from” syntax recurring quite a bit in Chapter 14 when we discuss inheritance. Permitted underlying ...
Read now
Unlock full access