0

如果我有 2 个枚举

typedef enum { 
type1,
type2,
type3
} enum_one;

typedef enum {
type4,
type5,
type6
} enum_two;

我想创建一个复合

typedef enum {
enum_one,
enum_two
} another_enum;

这是允许的吗?

4

1 回答 1

0

至少,您应该说明您的编程语言。

在 C/C++ 中是不允许的。枚举被实现为整数常量。你可以这样做:

typedef enum {
    newMember1 = enum_one.type1,
    newMember2 = enum_two.type4
} another_enum;

确切的语法可能会有所不同,具体取决于您的语言和编译器。

于 2013-09-16T12:24:18.877 回答