You can store the names in an array of strings, indexed by the enum
values.
enum Colours
{
Red =0,
Green=1,
Blue=2
};
char* names[3] = {"Red", "Green", "Blue"};
Then you can print: "Invalid colour '" + names[colour] + "' selected."
But this approach may not be very useful if you do not define the enum
values sequentially. In that case this approach will waste memory. Writing a function with a switch
over the enum
value would be useful, as Alexander Gessler has mentioned. Another alternative may be the map
from STL.