- Part 1: Variables and Data Types
- Part 2: Arrays
- Part 3: Functions
- Part 4: Conditional Statements
- Part 5: Looping
- Part 6: Pointers
- Part 7: Objects
- Part 8: Complex Data Types
Starting with C, there exists a way to define a fixed set of data. These are enumerators. Used through the keyword enum, this type of programming feature is often used to define certain values that will not be changed.
Enumerators work like arrays, in that their values are set to their order. In the example of the days of the week, the entry Sunday would have the value 0.
As a set of entries, enumerators can also have associated values. It is possible to use enumerators to hold values that stand for others.
Much like using objects in C++, an enumerator is a blueprint for entries. To use an enumerator, it must be defined in regard to a variable name.
When used as an associated value, a variable will have the value associated with the name in the enumerator. Otherwise, it will have the value of its index in the set.