鱼C论坛

 找回密码
 立即注册
查看: 1198|回复: 4

[已解决]枚举类型问题

[复制链接]
发表于 2018-10-15 10:44:45 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
只能把枚举值赋予枚举变量,不能把元素的数值直接赋予枚举变量。如:
    a=sum;
b=mon;
是正确的。而:
    a=0;
b=1;错误。
那么那个程序中p->tm_wday是数值啊。不是枚举值呀。。
要怎么理解呢?
最佳答案
2018-10-15 11:16:26
你这个旧版的吧?新版的好像没有这个限制
You can use the enumerated type to declare symbolic names to represent integer constants. By using the enum keyword, you can create a new “type” and specify the values it may have. (Actually, enum constants are type int ; therefore, they can be used wherever you would use an int .) The purpose of enumerated types is to enhance the readability of a program. The syntax is similar to that used for structures. For example, you can make these declarations:


enum 就是 int,只不过在输入的时候,允许特定的字符形式~
2.png
1.png
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2018-10-15 10:49:26 | 显示全部楼层
是不是要加(enum Weekday)p->tm_wday.
3.png
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-10-15 10:53:23 | 显示全部楼层
这里写着是0~~~6啊出来的应该是数值哇
5.png
4.png
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-10-15 11:16:26 | 显示全部楼层    本楼为最佳答案   
你这个旧版的吧?新版的好像没有这个限制
You can use the enumerated type to declare symbolic names to represent integer constants. By using the enum keyword, you can create a new “type” and specify the values it may have. (Actually, enum constants are type int ; therefore, they can be used wherever you would use an int .) The purpose of enumerated types is to enhance the readability of a program. The syntax is similar to that used for structures. For example, you can make these declarations:


enum 就是 int,只不过在输入的时候,允许特定的字符形式~
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-10-15 11:29:13 | 显示全部楼层
claws0n 发表于 2018-10-15 11:16
你这个旧版的吧?新版的好像没有这个限制

OK知道咯。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-12 12:02

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表