Why doesn't C++ use all uppercase enumerated values?
This article mainly explains "why C++ doesn't use all uppercase enumerated values". The content in the article is simple and clear, and it is easy to learn and understand. let's study and learn why C++ doesn't use all uppercase enumerated values.
Enum.5: do not use all uppercase enumerated values
Reason (reason)
Avoid conflicts with macro definitions.
Example, bad (negative example)
/ / 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 (implementation recommendation)
Marks all uppercase enumerated values.
Thank you for your reading, the above is the content of "Why C++ does not use all uppercase enumerated values". After the study of this article, I believe you have a deeper understanding of why C++ does not use all uppercase enumerated values. the specific use also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!