How can variables declared with enum be useful?

From my understanding, any variables that is declared inside the braces of enum has an internal integer value that is enumerated starting from 0 ,1, 2, 3, 4...(so on) and can be used in the main function, just like most other integer-type variables.

But my question is, how can this be useful? Every time I use a variable declared of enum type in main function, I can't seem to really change its value. The compiler keeps complaining about how 1value is required left of operand in assignment, but even after changing the positions of the operands, it still won't work

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>

using namespace std;

enum countries {us, russia, georgia, italy, ukraine};

int main ()
{
    countries DestructiveCountry, CowardlyCountry;

    DestructiveCountry = us;
    CowardlyCountry = russia;

    cout << DestructiveCountry << "\n";
    cout << CowardlyCountry << "\n";

    georgia = georgia + 2;   //here is where compiler says there's a problem

    cout << georgia << "\n";
}


Can anyone show me a good example showing how enum is useful?
Last edited on
Enums are a shortcut to grouping related global constants. The point is that the values are related to each other, that they can never change, and that you know what all of them are ahead of time.
ah I understand now, thank you
Topic archived. No new replies allowed.