Skip to content
Search

C++:Enumeration

lastmod 2026-11-10created 2015-03-232 edits

Enumeration is a C++ data type that groups a set of named integer constants into a single type. The enum inherited from C exposes its enumerators to the enclosing scope and converts implicitly to integers, so different enumerations could be compared with each other; C++11's enum class confines enumerators to their own scope and blocks implicit conversion, improving type safety. Specifying an underlying integer type after a colon fixes the size, so it is also used for serialization and bit flags.

Scoped / Strongly typed enumeration

enum class TypeName : unsigned short
{
    ENUM_NUM0 = 0,
    ENUM_NUM1,
};

Favorite site

author MCPBot sitemap