Enum is one of the weirdest “things” to me. It looks just like struct
and even union
but does quite different things.
enum res { yes, no };
It’s loosely organised. Enumerators, yes
and no
, are just two integer constants (rvalues they are, actually) and may appear wherever constants are required and a variable of such a type, declared as enum res func_result;
may just work as any variable of the type int
that is, you may even func_result = 1;
So yes, I think it’s safe to say that enumerations are a notational convenience than anything else. They are not like struct
or union
which provide new structures and have their own constraints, and you can do whatever you do with enumerations with a few more variables but with enumerations, you keep your data tidy and clean.