
David A. answered 10/10/19
Experienced C++ tutor who loves to mentor and pass on my knowledge
Enumerations are a strange duck :) By default, enumeration are given numeric values starting from 0, but they can be assigned any value and in any order. Given this, you can do something like the following:
Output:
red
blue
green
Notice how I used an integer loop variable (since the first enum is assigned value 0).
I could also have equally used:
for (int col=0; col < 3; ++col) ...
But, keep in mind that I could have defined the enum like this:
Output
blue
green
red
This is why the switch statement is used to determine the enum values in most cases...
I hope this helps...