1) C++98 的 enum 是“非域化的”;而 C++11 的 enum class 是“域化的”,限制了枚举成员只在域内可见 2) enum class 的缺省潜在类型 (underlying type) 是 int 型,而 enum 没有缺省潜在类型 3) enum class 一般总是前置声明,而 enum 只有在指定了潜在类型时才可以是前置声明 参考资料 《Effective Mod...
public abstract class Enum : ValueType, IComparable, IConvertible, ISpanFormattable Ereditarietà Object ValueType Enum Derivato Accessibility.AnnoScope Microsoft.Aspnet.Snapin.MMC_CONTROL_TYPE Microsoft.CSharp.ErrorLevel Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags Microsoft.CSharp.Runti...
enum class Status; // use of fwd-declared enum void continueProcessing(Status s); 2) 潜在类型enum class 的潜在类型 (underlying type),缺省为 int 型,当然也可自定义潜在类型。无论哪种方式,编译器都会预先知道枚举成员的大小1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 // underlying type...
access enum class enumeration-identifier [:underlying-type] { enumerator-list } [var]; access enum struct enumeration-identifier [:underlying-type] { enumerator-list } [var]; 参数访问 枚举的辅助功能,可以是 public 或 private。 枚举标识符 枚举的名称。 基础类型 (可选) 枚举的基础类型。 (可选)...
2. conventional enums export their enumerators to the surrounding scope, causing name clashes. 3. the underlying type of an enum cannot be specified, causing confusion,compatibility problems, and makes forward declaration impossible. The new enums are "enum class" because they combine aspects of ...
默认的类型更容易读写。int是默认的整数类型。int和C语言枚举类型兼容。 Example(示例) 代码语言:javascript 代码运行次数:0 enumclassDirection:char{n,s,e,w,ne,nw,se,sw};// underlying type saves spaceenumclassWeb_color:int32_t{red=0xFF0000,green=0x00FF00,blue=0x0000FF};// underlying type is...
File name or class name not found during Automation operation File not found (Visual Basic Run-Time Error) First operand in a binary 'If' expression must be nullable or a reference type First statement of this 'Sub New' must be a call to 'MyBase.New' or 'My...
Returns the type code of the underlying type of this enumeration member. GetUnderlyingType(Type) Returns the underlying type of the specified enumeration. GetValues(Type) Retrieves an array of the values of the constants in a specified enumeration. GetValues<TEnum>() Retrieves an array of...
Underlying Type of an Enum Requirements Compiler option:/clr Examples C++ // mcppv2_enum_2.cpp// compile with: /clr// managed enumpublicenumclassm{a, b };// standard enumpublicenumn { c, d };// unnamed, standard enumpublicenum{ e, f } o;intmain(){// consume managed enumm mym...
getUnderlyingType Gets this type after typedefs have been resolved. from Type getUnspecifiedType Gets this type after specifiers have been deeply stripped and typedefs have been resolved. from Type hasDeclaringType Holds if this declaration is a member of a class/struct/union. from Declaration has...