Definition of enum type
the general form of an enumeration type definition is:
Enum Enum Name {enumeration value list};
Lists all available values in the enumeration values list. These values are also known as enumeration elements, the enumeration values are constants, not variables, and the enumeration elements themselves are defined by the system as a numeric value that represents an ordinal, defined as 0,1,2 in the order of 0.
For example:
Enum weekday{Sunday, Monday, Tuesday, Wednesday, Thursday, Fridar, Satur Day};
define enum variable enum WeekDay enumeration variable name;
Define enum variable enum WeekDay oneday = Sunday;
Full code:
#include <corefoundation/corefoundation.h>int main (int argc, const char * argv[]) { enum weekday{ sunday , monday, tuesday, wednesday, thursday, fridar, saturday }; // Defining enumeration variables enum WeekDay oneDay = sunday; if (oneday == sunday | | oneday == saturday) { printf ("Rest day \ n"); }else{ printf ("Business day \ n"); } printf ("Numerical Value:%d\n", OneDay); return 0;}
The output results are as follows:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/46/6C/wKioL1PyLOGAyk1sAABc4TO58t8655.jpg "title=" Enum uses. png "alt=" wkiol1pylogayk1saabc4to58t8655.jpg "/>
This article is from the "7803002" blog, please be sure to keep this source http://7813002.blog.51cto.com/7803002/1541820