0
如果我有2個枚舉是否有可能引入一個枚舉到另一個
typedef enum {
type1,
type2,
type3
} enum_one;
typedef enum {
type4,
type5,
type6
} enum_two;
我想創建一個複合
typedef enum {
enum_one,
enum_two
} another_enum;
這可以嗎?
如果我有2個枚舉是否有可能引入一個枚舉到另一個
typedef enum {
type1,
type2,
type3
} enum_one;
typedef enum {
type4,
type5,
type6
} enum_two;
我想創建一個複合
typedef enum {
enum_one,
enum_two
} another_enum;
這可以嗎?
你應該說明你的編程語言,至少。
在C/C++中是不允許的。枚舉被實現爲整型常量。 你可以做這樣的事情:
typedef enum {
newMember1 = enum_one.type1,
newMember2 = enum_two.type4
} another_enum;
確切的語法可以是不同的,這取決於你的語言和編譯器。