Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to use cast of enumeration type?
How to use cast of enumeration type?
Enumeration only declares a memory space, and there is no assignment. These elements * * * all share the same memory space. Therefore, the statements enumbox {p = 10, p 1 = 12, p2 = 14} only declare a space, and do not play the role of assignment.

Test = (enumeration box) 0; This sentence really plays the role of assignment, which means that the test memory space is box-shaped. In this memory space, the assignment is 0, so the running result must be 0. If it is test = p;; Then it means that the assignment is p, which is 10.

Test = (enumeration box) 0; It cannot be understood that p, p 1, p2 is forcibly converted into integer 0, 1, 2, because the value of p, p 1, p2 is defined in the declaration and cannot be changed in the later use.

Enumeration box {p= 10, p 1= 12, p2 =14}; P, p 1, p2 can't be understood as variables, they just declare a constant. It can be understood that the constants 10, 12 and 14 are named P, p 1, p2 respectively. Because it is not a variable, it cannot be assigned or changed.