Write out your answers for these questions on a separate piece of paper.
Question #1: An enumeration is a new ____________ in a C++ program.
Question #2: The values of an enumeration are called ____________.
Question #3:
Why is an enumeration preferable to a string
?
Question #4: A value of an enumeration is similar to a(n) ____________, and so we use the same rules for naming their identifiers.
Question #5: The ____________ increments the variable before returning a value.
Code #1:
Write an enumeration declaration for Color
with enumerators
for red, green, and blue.
Code #2:
Declare the variable theColor
to be of type Color
,
initialized to represent the color red.
Code #3:
Write an expression to increment theColor
(assuming the
operator has been defined).
Code #4:
Write another (different) expression to increment theColor
(assuming that this other operator has also been defined).
Code #5:
Write an expression to see if theColor
stores the enumerator
for the color blue.