“typedef enum ABCD {0,1};”之间的差异和typedef enum {0,1} ABCD; [英] difference between "typedef enum ABCD{0,1};" and typedef enum {0,1}ABCD;

查看:107
本文介绍了“typedef enum ABCD {0,1};”之间的差异和typedef enum {0,1} ABCD;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我想知道以下两个陈述之间的区别。



typedef enum COLOR {

RED,
白色

};



typedef enum {

RED,

白色

}颜色;

Hi all, i want to know the difference between following two statements.

typedef enum COLOR{
RED,
WHITE
};
and
typedef enum {
RED,
WHITE
}COLOR;

推荐答案

假设你用合法的枚举器名称替换0和1,那么第一个是冗余的typedef(你可以把它留下),第二个为一个未命名的枚举类型定义一个别名。

干杯

Andi
Assuming you replace the 0 and 1 with legal enumerator names, then the first is a redundant typedef (you can leave it away) and the second defines an alias for an otherwise unnamed enum type.
Cheers
Andi


两者都是 C ++ 中的无效语句(以及 C )。

请参阅:枚举声明 [ ^ ]。
Both are invalid statements in C++ (as well in C).
Please see: "enumeration declaration"[^].


是的,两者都在编译并正常工作。我只是想知道它们之间有什么区别吗?
Yes, both are compiling and working fine. I just want to know is any difference between them ??


这篇关于“typedef enum ABCD {0,1};”之间的差异和typedef enum {0,1} ABCD;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆