I'm debugging a C++ application, where one of the parameters is an enum.
I want to print out the string representation of the parameter... what's the easiest/quickest/best way to do it in C++?
If it were Euphoria (a language I'm much more familiar with) I'd do it like this:
(values changed to protect the innocent)
constant
ONE = 1,
TWO = 2,
PURPLE = 3,
FIVE = 4,
GOLDFISH = 5
constant lookup = {"ONE", "TWO", "PURPLE", "FIVE", "GOLDFISH" } //(1-based arrays)
procedure printEnum(integer enum)
printf(1, "Value is: %s\n, {lookup[enum]})
end procedure |