Forward Declaration of Enums (C++11)
Go Up to C++11 Features Index
BCC32 introduces forward declaration of enums. You can declare an enumeration without providing a list of enumerators. Such declarations would not be definitions and can be provided only for enumerations with fixed underlying types. An enumeration can then be re-declared, possibly providing the missing list of enumerators, but the re-declaration must match the previous declaration. This feature is one of the C++11 features added to BCC32.
enum E : short; // OK: unscoped, underlying type is short
enum F: // illegal: enum-base is required
enum class G : short // OK: scoped, underlying type is short
enum class H; // OK: scoped, underlying type is int
enum E : short; // OK: redeclaration of E
enum class G : short; // OK: redeclaration of G
enum class H; // OK: redeclaration of H
enum class H : int; // OK: redeclaration of H
enum class E : short; // illegal: previously declared as unscoped
enum G : short; // illegal: previously declared as scoped
enum E; // illegal: enum-base is required
enum E : int // illegal: different underlying type
enum class G; // illegal: different underlying type
enum class H : short; // illegal: different underlying type
enum class H {/* */}] // OK: this redeclaration is a definition