Enumeration type definition

An enumeration type definition contains the enum keyword followed by an optional identifier (the enumeration tag) and a brace-enclosed list of enumerators. A comma separates each enumerator in the enumerator list.

Read syntax diagramSkip visual syntax diagramEnumeration definition syntax
 
                                .-,----------.
                                V            |
>>-enum--+----------------+--{----enumerator-+--}--;-----------><
         '-tag_identifier-'
 

The tag_identifier gives a name to the enumeration type. If you do not provide a tag name, you must put all variable definitions that refer to the enumeration type within the declaration of the type, as described in Enumeration type and variable definitions in a single statement. Similarly, you cannot use a type qualifier with an enumeration definition; type qualifiers placed in front of the enum keyword can only apply to variables that are declared within the type definition.

C++ C++ supports a trailing comma in the enumerator list.



[ Top of Page | Previous Page | Next Page | Contents | Index ]