Перечисления C++ начинаются с 0?C++

Программы на C++. Форум разработчиков
Гость
Перечисления C++ начинаются с 0?

Сообщение Гость »


If I have an that does not assign numbers to the enumerations, will its ordinal value be 0? For example:

Код: Выделить всё

enum enumeration { ZERO,
ONE,
TWO,
THREE,
FOUR,
FIVE,
SIX,
SEVEN,
EIGHT,
NINE };
I've been able to find a post citing that the C99 standard requires a 0 ordinal number. But I know C++ ignores several things in the C99 standard. And I've also been able to find a post witnessing the compiler using an ordinal value of 1, something I also seem recall seeing, though I can't say how long ago that was.
I would really like to see an answer that confirms this for C++, but I'd also like to know if an ordinal 0 holds even if I specify a value in the middle of an :

Код: Выделить всё

enum enumeration { ZERO,
ONE,
TWO,
THREE = 13,
FOUR,
FIVE,
SIX,
SEVEN,
EIGHT,
NINE };


Источник: https://stackoverflow.com/questions/348 ... start-at-0

Вернуться в «C++»