Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
enum
◄Up► ◄Contents► ◄Index► ◄Back►
────────────────────────────────────────────────────────────────────────────
Keyword: enum
Syntax: enum [tag] {enum-list} [declarator];
enum tag declarator;
Summary: Defines an enum type and/or an enum variable.
If braces are given, the enum keyword declares an enum type
consisting of a set of named integer constants. A variable of an
enum type holds one of the values defined by the enum type. Thus,
an enum variable always has int type. Each item in an <enum-list>
has the form:
<identifier> [= <constant-expression>]
If an item is not initialized, it has the value of the last item
in the list plus one. If the first item in the list is not
initialized, it has the value zero.
If braces are not given, the enum keyword is used to define an
enum variable having a previously defined enum type. The tag
identifies the type.
An enum can also be used to declare constants, which can be used
by name even if no variable is declared for them, as shown in the
following example:
enum DAYS // Declare enum type DAYS
{
saturday, // saturday and sunday have
// value 0
sunday = 0,
monday, // monday = 1, tuesday = 2,
// etc.
tuesday,
wednesday,
thursday,
friday
} today; // Variable today has type DAYS
enum DAYS yesterday = monday; // Variable yesterday has type
// DAYS, value monday
int tomorrow = wednesday; // Int variable can have enum
// constant
-♦-