enumsenum values and operations.md - brainchildservices/curriculum GitHub Wiki

Slide 1

Enum values and operations

Each enum type defines a distinct type; an explicit enumeration conversion (Explicit enumeration conversions) is required to convert between an enum type and an integral type, or between two enum types. The set of values that an enum type can take on is not limited by its enum members. In particular, any value of the underlying type of an enum can be cast to the enum type, and is a distinct valid value of that enum type.

Enum members have the type of their containing enum type (except within other enum member initializers: see Enum members). The value of an enum member declared in enum type E with associated value v is (E)v.

The following operators can be used on values of enum types: ==, !=, <, >, <=, >= (Enumeration comparison operators), binary + (Addition operator), binary - (Subtraction operator), ^, &,|(Enumeration logical operators), ~ (Bitwise complement operator), ++ and -- (Postfix increment and decrement operators and Prefix increment and decrement operators).

⚠️ **GitHub.com Fallback** ⚠️