Enum is list of constant integer values. It can be used instead of defining constant values using #define. But other than that, I haven't found any substantial uses of enums in C and CPP. Can any one please let me know what are the exact uses of enums.
Initially I thought if we create a enum variable and assign a value which is not in the enum values, the compiler will shout. But that is not true. We can assign any value to the enum variable. I can't think of any substantial uses of enum.
Advantages over macros
#define
, you have to commit to int
or some typedef and ensure that all the constants fit manually