[DiscordArchive] are enums starting with 0 in C++?
[DiscordArchive] are enums starting with 0 in C++?
Archived author: Skarn • Posted: 2018-10-21T18:57:06.475000+00:00
Original source
are enums starting with 0 in C++?
Archived author: MaxtorCoder • Posted: 2018-10-21T19:01:11.159000+00:00
Original source
Yes
Archived author: MaxtorCoder • Posted: 2018-10-21T19:01:34.808000+00:00
Original source
The enumeration type declared with an enum-key of only enum is an unscoped enumeration, and its enumerators are unscoped enumerators. The enum-keys enum class and enum struct are semantically equivalent; an enumeration type declared with one of these is a scoped enumeration, and its enumerators are scoped enumerators. The optional identifier shall not be omitted in the declaration of a scoped enumeration. The type-specifier-seq of an enum-base shall name an integral type; any cv-qualification is ignored. An opaqueenum-declaration declaring an unscoped enumeration shall not omit the enum-base. The identifiers in an enumerator-list are declared as constants, and can appear wherever constants are required. An enumeratordefinition with = gives the associated enumerator the value indicated by the constant-expression. If the first enumerator has no initializer, the value of the corresponding constant is zero. An enumerator-definition without an initializer gives the enumerator the value obtained by increasing the value of the previous enumerator by one.
https://stackoverflow.com/questions/3481...start-at-0
[Embed: Do C++ enums Start at 0?]
If I have an enum that does not assign numbers to the enumerations, will it's ordinal value be 0? For example:
enum enumeration { ZERO,
ONE,
TWO,
...
https://stackoverflow.com/questions/3481...start-at-0