C++核心準(zhǔn)則Enum.5: 不要使用全部大寫的枚舉值

Enum.5: Don't use?ALL_CAPS?for enumerators
Enum.5: 不要使用全部大寫的枚舉值
Reason(原因)
Avoid clashes with macros.
避免和宏定義發(fā)生沖突。
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 errorEnforcement(實施建議)
Flag ALL_CAPS enumerators.
標(biāo)記全部大寫的枚舉值。
原文鏈接:
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#enum5-dont-use-all_caps-for-enumerators
覺得本文有幫助?請分享給更多人。
關(guān)注【面向?qū)ο笏伎肌枯p松學(xué)習(xí)每一天!
面向?qū)ο箝_發(fā),面向?qū)ο笏伎迹?/span>
評論
圖片
表情
