Enumerations Flashcards
Enumerated Type
A data type whose list of values is specified by the programmer in a type declaration
Enumeration Constant
An identifier that is one of the values of an enumerated type
Declaring an Enumeration
typedef enum
{name, next_name}
enum_name;
(inside of a function)
enum_name enum_kind;
Using an Enumaration
Value of enumeration kind is the name of enumeration.
Assign an integer value to &enum_kind to get name of enumeration.
Enumerated Type Definition
Syntax:
typedef enum
{identifier_list}
enum_type;
Interpretation:
A new data type named enum_ type is defined. The valid values of this type are the identifiers of identifier_ list . The first identifier is represented by the integer 0, the second by the integer 1, and so on. A particular identifier can appear in only one identifier_ list in a given scope.
What kind of operators can be used with enumerated types?
Relational, assignment, and arithmetic.