“typedef enum ABCD {0,1};”之间的差异和typedef enum {0,1} ABCD;

编程入门 行业动态 更新时间:2024-10-24 10:25:03
本文介绍了“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;

本文发布于:2023-11-30 00:39:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648148.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:差异   typedef   enum   ABCD

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!