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...

The best use for linking text boxes is to create a:

A) Newsletter. B) Brochure. C) Flyer. D) Booklet.

Computer Science & Information Technology

The advantage of device-dependent operating systems is that users can retain existing application software and data even if they change computer or mobile device models or vendors.

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

Computer Science & Information Technology

What type of tunnel is created between the client computer and a DirectAccess server, and is used for control of the DirectAccess connection?

A. Infrastructure tunnel B. Intranet tunnel C. Internet tunnel D. Split tunnel

Computer Science & Information Technology

The technology to obtain and validate tickets from mobile devices is called:

a. eTicketing. b. iTicketing. c. mobile ticketing. d. integrated ticketing.

Computer Science & Information Technology