“枚举类型”与“枚举变量”有什么区别?

enum WEEKDAY{Monday,Tuesday,Wednesday};
enum WEEKDAY w;
称enum WEEKDAY为枚举类型,称w为枚举变量,称Monday等为枚举值(好像也有叫枚举常量的).
追问:
那么w枚举变量所对应的,是Monday等枚举值吗?
追答:
是的。比如可以这么用: w = Monday; switch (w){ case Monday: printf("Monday"); break; case Tuesday: printf("Tuesday"); break; case Wednesday: printf("Wednesday"); break; }

posted @ 2017-12-20 15:16  星朝  阅读(4438)  评论(0编辑  收藏  举报