Enumerations Simple list of constants: Simple list of constants: enum { red, green };// the enum { } doesnt define a scope int a = red;// red is available here enum { red, blue, purple };// error: red defined twice Type with list of constants Type with list of constants enum Color { red, green, blue, /* … */ }; enum Month { jan, feb, mar, /* … */ }; Month m1 = jan; Month m2 = red;// error red isnt a Month Month m3 = 7;// error 7 isnt a Month int i = m1;// ok: an enumerator is converted to its value, i==0 19Stroustrup/Programming
{}