Enumerations

I just had a question about enumerations (relating to an exercise out of "Beginning C++ through game programming")

The exercise has you edit the following program using an enumeration to represent difficulty levels.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Menu Chooser
// Demonstrates the switch statement

#include <iostream>
using namespace std;

int main()
{
	cout << "Difficulty Levels\n\n";
	cout << "1 - Easy\n";
	cout << "2 - Normal\n";
	cout << "3 - Hard\n\n";

	int choice;
	cout << "Choice: ";
	cin >> choice;

	switch (choice)
	{
	case 1:
			cout << "You picked Easy!\n";
			break;
	case 2:
			cout << "You picked Normal!\n";
			break;
	case 3:
			cout << "You picked Hard!\n";
			break;
	default:
			cout << "You made an illegal choice.\n";
	}

    return 0;
}


I added the line
enum difficulty{ EASY,NORMAL,HARD};
and edited the switch cases accordingly

What I want to know is, What's the purpose of the enumerations? It seems like a waste of time (atleast in this case) to use them.
They make a code more clear and readable.
Topic archived. No new replies allowed.