当前位置:网站首页>Enumeration type
Enumeration type
2022-07-28 14:57:00 【Swlaaa】
Enumeration type (enumeration) yes C++ A derived data type in , It's a collection of user-defined enumeration constants .
If a variable has only a few possible values , It can be defined as enumeration (enumeration) type . So-called " enumeration " It means to list the values of variables one by one , The value of a variable can only be in the range of listed values .
Create enumeration , Keyword required enum. The general form of enumeration type is :
enum Enum name {
identifier [= Integer constant ],
identifier [= Integer constant ],
...
identifier [= Integer constant ]
} Enumerate variables ;If the enumeration is not initialized , I.e. omit "= Integer constant " when , Start with the first identifier .
for example , The following code defines a color enumeration , Variable c The type of color. Last ,c To be an assignment "blue".
enum color { red, green, blue } c;
c = blue;By default , The value of the first name is 0, The value of the second name is 1, The value of the third name is 2, And so on . however , You can also assign a special value to the name , Just add an initial value . for example , In the enumeration below ,green The value of is 5.
enum color { red, green=5, blue };ad locum ,blue The value of is 6, Because by default , Each name will be larger than the one before it 1, but red The value of is still 0.
边栏推荐
- Brief introduction and use of mqtt entry level
- It's so hot that solar power can't take off? Hello, head
- Crawler: from entry to imprisonment (II) -- Web collector
- Summarize the knowledge points of the ten JVM modules. If you don't believe it, you still don't understand it
- How to reduce the resolution of only 3D camera but not UI camera
- Swiftui 4.0's new navigation system
- OKR and grad
- SwiftUI 布局 —— 尺寸( 上 )
- C language: mathematical method of converting decimal system into binary system
- QT qbuttongroup realizes single selection and multiple selection
猜你喜欢

VTK notes - picker picker summary

Redis redis use in jedis

@Solution to DS ('slave') multi data source compatible transaction problem

看了就会的 Rainbond 入门教程

Product Manager

Raspberry pie foundation | summarize and record some operations in the learning process of raspberry pie

MITK create module

数字化转型安全问题频发,山石网科助力数字政府建设

How to make the characters in the photos laugh? HMS core video editing service one click smile function makes people smile more naturally

Hcip day 11
随机推荐
Log management platform of infrastructure and nail & email alarm notification
VTK annotation class widget vtkborderwidget
Tensorflow GPU installation process record
C language program: judging triangles
Namespace conflict problem
【LeetCode】 贴纸拼词(动态规划)
多线程顺序运行有几种方法?
使用Weka与Excel进行简单的数据分析
C # read INI file and key value pair operation
SSH service
SwiftUI 的动画机制
Keras reported an error using tensorboard: cannot stop profiling
面试官:ThreadLocal使用场景有哪些?内存泄露问题如何避免?
Using keras to visualize the network model, failed to import pydot appears
C language exercises
Multi merchant mall system function disassembly lecture 17 - platform side order list
为自定义属性包装类型添加类 @Published 的能力
Error reason for converting string to long type: to convert to long type, it must be int, double, float type [easy to understand]
3、 C language storage class
58 sub station Anju, broker marketing management platform login interface encryption reverse