-1
我有一个包含“枚举结构”将无法编译,除非<iostream>包括
enum struct cols: int8_t {red, blue, green};
当我编译,我得到错误的行代码:
test.cpp:4:1: warning: elaborated-type-specifier for a scoped enum must not use the 'struct' keyword
enum struct cols: int8_t {red, blue, green};
^
test.cpp:4:13: error: use of enum 'cols' without previous declaration
enum struct cols: int8_t {red, blue, green};
^
test.cpp:4:17: error: expected unqualified-id before ':' token
enum struct cols: int8_t {red, blue, green};
^
但是,如果我把行
#include <iostream>
在顶部,它编译没有投诉。
对此有解释吗?
(我用克++ 4.9.4,但也与克++ 5.4.0显示这种行为。)