Enum.5: Don't use ALL_CAPS for enumerators
Enum.5: 不要使用全部大写的枚举值
Reason(原因)
Avoid clashes with macros.
避免和宏定义发生冲突。
Example, bad(反面示例)
// webcolors.h (third party header)
#define RED 0xFF0000
#define GREEN 0x00FF00
#define BLUE 0x0000FF
// productinfo.h
// The following define product subtypes based on color
enum class Product_info { RED, PURPLE, BLUE }; // syntax error
Enforcement(实施建议)
Flag ALL_CAPS enumerators.
标记全部大写的枚举值。
原文链接:
扫描二维码关注公众号,回复:
11204989 查看本文章
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#enum5-dont-use-all_caps-for-enumerators
觉得本文有帮助?欢迎点赞并分享给更多的人。
阅读更多更新文章,请关注微信公众号【面向对象思考】