Enums in java

In prior releases, the standard way to represent an enumerated type was the int Enum pattern: **// int Enum Pattern - has severe problems!** public static final int SEASON\_WINTER = 0; public static final int SEASON\_SPRING = 1; public static final int SEASON\_SUMMER = 2; public static final int SEASON\_FALL = 3; But these are not type safe, and clearly naming them is bit of a problem. So in Java 5, they introduced Enums. [Read More]

Enum in c++

The problem: representing series of values It is very common to have a series of values that need to be represented. For example, to simulate a traffic light requires representing three values (red, yellow, and green), but there is no built-in C++ color datatype. Use integer values to represent colors, for example red as 0, yellow as 1, and green as 2. There is nothing “green” about the value 2, and it could just as easily be represented by some other number. [Read More]