What is an enumeration and what are the advantages of creating an enumeration type? Show an example of an enumeration definition.

What will be an ideal response?

An enumeration is a set of constants represented by identifiers. An example of an enumeration definition is the following:
enum DayOfWeek
{
SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY,
SATURDAY
}
Creating an enumeration type provides several advantages. For example, the DayOfWeek type above improves a program as follows:
1. Only the seven allowed values can be assigned to a DayOfWeek object.
2. Using an enumeration type makes a program type-safe (for example, you couldn't use an integer method such as addition on an object of type DayOfWeek).
3. The enum constants provide clearer self-documentation (it is more apparent what you mean when you assign a variable the value WEDNESDAY rather than the number 4, for example).

Computer Science & Information Technology

You might also like to view...

A Word document can be converted into HTML without losing any aspect of the original document.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

A 150% Vertical Scale changes the height of the selected text.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology