2. Enumeration type
Enumeration is a named collection of integer constants, which is very common in daily life.
For example, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday,
Saturday is an enumeration.
In the theory of mathematics and computer science, enumeration of sets is a program that lists all members of some finite sequence sets, or counts a specific type of objects. These two types often (but not always) overlap.
Enumeration is a named collection of integer constants, which is very common in daily life. For example, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday and Saturday are enumerations.
The description of enumeration is similar to structure and union, and its form is: enum enumeration name {identifier [= integer constant], identifier [= integer constant], ... identifier [= integer constant],} enumeration variable; If the enumeration is not initialized, that is, when the = integer constant is omitted, it starts with the first identifier and the sequence is
Identifier 0, 1, 2, ... However, when a member in the enumeration is assigned a value, subsequent members determine its value according to the rule of 1 adding in turn.
For example, after the following enumeration, the values of x 1, x2, x3, x4 and x4 are 0, 1, 2 and 3 respectively. Enumeration string {x 1, x2, x3, x4} x. When the definition is changed to: enumstring {x 1, x2 = 0, x3 = 50, x4,} x;; Then x 1 = 0, x2 = 0, x3 = 50, x4 = 5 1 Note: 1. The terminator of each member (identifier) in the enumeration is, instead of. The last member can be omitted.
,。
2. A negative number can be assigned during initialization, and 1 will be added to subsequent identifiers in turn. 3. Enumeration variables can only accept one identifier constant in the enumeration description structure. For example: enumstring {x 1 = 5, x2, x3, x4,}; Enumeration string x = x3 At this point, the enumeration variable x is actually 7. In the theory of mathematics and computer science, enumeration of sets is a program that lists all members of some finite sequence sets, or counts a specific type of objects. These two types often (but not always) overlap.
Enumeration is a named collection of integer constants, which is very common in daily life. For example, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday and Saturday are enumerations.
The description of enumeration is similar to structure and union, and its form is: enum enumeration name {identifier [= integer constant], identifier [= integer constant], ... identifier [= integer constant],} enumeration variable; If the enumeration is not initialized, that is, when the = integer constant is omitted, it starts with the first identifier and the sequence is
The secondary identifiers are 0, 1, 2, ... However, when a member in the enumeration is assigned a value, the subsequent members determine its value according to the rule of 1 adding in turn.
For example, after the following enumeration, the values of x 1, x2, x3, x4 and x4 are 0, 1, 2 and 3 respectively. Enumeration string {x 1, x2, x3, x4} x. When the definition is changed to: enumstring {x 1, x2 = 0, x3 = 50, x4,} x;; Then x 1 = 0, x2 = 0, x3 = 50, x4 = 5 1 Note: 1. The terminator of each member (identifier) in the enumeration is, instead of. The last member can be omitted.
2. A negative number can be assigned during initialization, and 1 will be added to subsequent identifiers in turn. 3. Enumeration variables can only accept one identifier constant in the enumeration description structure.