I learned enums when I learned C and from time to time I keep myself reminding about it and most of the time by re-reading from some source,it occurred to me that this is d
enums can make code easier to read and may present better type checking during compilation.
int or
unsigned int and assigned into
those kind of variables, thus
creating a hole in the type checking
benefit.enum to
std::cout results in the enum
converted to an integer then printed
out. Most implementations must
perform a table lookup to convert
the enum to text before printing.Another alternative to enum is to use a string. I've worked at shops where they pass a constant string instead of an enum. One advantage is that the named value is always available, even when debug symbols are not. Also there are no conversions required when printing.
switch statement.