The usage of anonymous enums

后端 未结 8 735
无人及你
无人及你 2020-11-29 19:40

What is the purpose of anonymous enum declarations such as:

enum { color = 1 };

Why not just declare int color = 1

8条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 20:20

    If this is old code, then enum might have been used for the "enum hack".

    You can learn more about the "enum hack", for example, in this link: enum hack

提交回复
热议问题