enum class ClassName { VAL1 = 0, VAL2, VAL3 }; const char* str(ClassName val) { static const char* asString[] = { "VAL1", "VAL2", "VAL3" }; return asString[(int)val]; }