看着enum文档 http://en.cppreference.com/w/cpp/language/enum,我注意到一件事:
enum-key- 其中之一enum
, enum class
(自 C++11 起),或enum struct
(自 C++11 起)
enum
and enum class
,当然,但是什么是enum struct
?
文档似乎是这么说的enum class
and enum struct
完全相同:
[...] 范围枚举(声明与enum-key enum class
or enum struct
)
-
enum struct
|class
name { enumerator = constexpr , enumerator = constexpr , ... }
- [...]
它们真的一模一样吗?还是有什么我错过的差异?对于同一事物使用两种不同的语法有什么意义(如果它们相同)?
enum class
and enum struct
是相同的(强调我的)。
7.2 Enumeration declarations
...
2 .... The enum-keys enum class
and enum struct
are semantically equivalent;
an enumeration type declared with one of these is a scoped enumeration, and its enumerators are scoped
enumerators.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)