First, the language does not provide any means of matching the internal enum value for a string. This is actually impossible; consider the following issues:
enum Numbers { one = 1, two = 2, three = 3, un = 1, deux = 2, trois = 3 };
Once you have assigned the enum constant to the enum variable, it contains a numerical value and nothing else. And if the numerical value in the above example is 2, how the system can know whether it should be displayed on two or on deux .
In practice, mapping is useful in many contexts. A while back, I wrote a simple parser to generate display code; it ignores most C ++, will not work in cases where, for example, enum is wrapped in a macro, the code that it generates will not compile if enum is private or protected, and it is undefined which line you get in such cases as above, but I still found it extremely useful.
For the second question: anonymous enumerations are usually used when the only purpose of an enumeration is to generate constants. things like:
enum { maxSize = 4096 };
were widely used before you could provide initialization constant for static member variables. And I often found it convenient to define bit masks using an anonymous enumeration, even when the actual values ββwere on some unsigned type. Such things as:
enum { offsetMask = 0xF000, offsetShift = 12, NS = 0x100, CWR = 0x80, ECE = 0x40, URG = 0x20, ACK = 0x10,
I do not want to declare my variables for enumeration; they must be exactly 16 bits (according to the TCP specification). In C, I would probably use #define , and in modern C ++ I could use static uint16_t const member variables, but through most of my career in C ++, something like the above would be a normal solution.