Two enums have some elements in common, why does this produce an error?

后端 未结 8 679
难免孤独
难免孤独 2021-01-01 09:17

I have two enums in my code:

enum Month {January, February, March, April, May, June, July,
        August, September, October, November, December};
enum Shor         


        
相关标签:
8条回答
  • 2021-01-01 09:49

    What unwind said. But I'd also like to say that your example seems like a pretty unusual use of enums. I can't see the value of having a ShortMonth and a LongMonth both referring to the same thing - this would make sense for strings, but not for enums. Why not just have a single Month enum type?

    0 讨论(0)
  • 2021-01-01 09:52
    typedef enum {Jan, January, Feb, February, Mar, March, Apr, April, May, Jun, June, Jul, July,
        Aug, August, Sep, September, Oct, October, Nov, November, Dec, December} Month,ShortMonth;
    

    Merge them become one

    0 讨论(0)
提交回复
热议问题