Why can two different enum enumeration-constants have the same integer value?

前端 未结 5 1160
半阙折子戏
半阙折子戏 2021-01-31 14:08

I know that if I defined an enum weekday like this:

enum weekday {
    MON,
    TUE,
    WED,
    THU,
    FRI,
};

Then, MON would internally e

5条回答
  •  梦毁少年i
    2021-01-31 14:48

    The name of the enumeration constant is used to assign the value and not the actual value itself. If you assign the value 0 to today the output value will be 0. And yes, both MON and TUE will have the value 0 and the remaining will assigned the value as WED=1 THU=2 and so on.

提交回复
热议问题