// A custom enumeration.
enum EmpType
{
Manager, // = 0
Grunt, // = 1
Contractor, // = 2
VicePresident // = 3
}
The EmpType enumeration defines four named constants, corresponding to discrete numerical
values. By default, the first element is set to the value zero (0), followed by an
n+1 progression. You
are free to change the initial value as you see fit. For example, if it made sense to number the mem-
bers of EmpType as 102 through 105, you could do so as follows:
// Begin with 102.
enum EmpType
{
Manager = 102,
Grunt, // = 103
Contractor, // = 104
VicePresident // = 105
}
Enumerations do not necessarily need to follow a sequential ordering, and need not have
unique values. If (for some reason or another) it makes sense to establish your EmpType as shown
here, the compiler continues to be happy:
Do'stlaringiz bilan baham: |