Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

When does C++ specify the enumeration value

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

The main content of this article is "when does C++ specify the enumeration value", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn when C++ specifies the enumeration value.

Enum.8: specify enumerated values only if necessary

Reason (reason)

It's the easiest way. Duplicate enumerated values can be avoided. By default, a set of continuous values is assigned that can be easily used by switch statements.

Example (sample)

Enum class Col1 {red, yellow, blue}

Enum class Col2 {red = 1, yellow = 2, blue = 2}; / / typo

Enum class Month {jan = 1, feb, mar, apr, may, jun

Jul, august, sep, oct, nov, dec}; / / starting with 1 is conventional

Enum class Base_flag {dec = 1, oct = dec

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report