// prior versions of C++ which need NULL to be defined as 0 typedef void *nullptr_t; // ANSI C which defines NULL as ((void*)0) */ Strongly typed enumerations In C++03, enumerations are not type-safe. They are effectively integers, even when the enumeration types are distinct. This allows the comparison between two enum values of different enumeration types. The only safety that C++03 provides is that an integer or a value of one enum type does not convert implicitly to another enum type. Further, the underlying integral type is implementation-defined; code that depends on the size of the enumeration is thus non-portable. Lastly, enumeration values are scoped to the enclosing scope. Thus, it is not possible for two separate enumerations in the same scope to have matching member names. C++11 allows a special classification of enumeration that has none of these issues. This is expressed using the enum class (enum struct is also accepted as a synonym) declaration: enum class Enumeration { Val1, Val2, Val3 = 100, Val4 // = 101 }; This enumeration is type-safe. Enum class values are not implicitly converted to integers. Thus, they cannot be compared to integers either (the expression Enumeration::Val4 == 101 gives a compile error). The underlying type of enum classes is always known. The default type is int; this can be overridden to a different integral type as can be seen in this example: enum class Enum2 : unsigned int {Val1, Val2}; With old-style enumerations the values are placed in the outer scope. With new-style enumerations they are placed within the scope of the enum class name. So in the above example, Val1 is undefined, but Enum2::Val1 is defined. There is also a transitional syntax to allow old-style enumerations to provide explicit scoping, and the definition of the underlying type: enum Enum3 : unsigned long {Val1 = 1, Val2}; In this case the enumerator names are defined in the enumeration's scope (Enum3::Val1), but for backwards compatibility they are also placed in the enclosing scope. Forward-declaring enums is also possible in C++11. Formerly, enum types could not be forward-declared because the size of the enumeration depends on the definition of its members. As long as the size of the enumeration is specified either implicitly or explicitly, it can be forward-declared: enum Enum1; // Invalid in C++03 and C++11; the underlying type cannot be determined. enum Enum2 : unsigned int; // Valid in C++11, the