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

前端 未结 5 1206
半阙折子戏
半阙折子戏 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:41

    It's as philosophical (or not) as

    #define ZILCH 0
    #define NADA  0
    

    There are many uses where it makes sense to have different names result in the same number.

提交回复
热议问题