枚举转字符串
#include <iostream>
using namespace std;
enum Abc { AAA = -1, BBB = 0, CCC = 1 };
class EnumToStringUtil {
public:
static const char* ConvertAbcToString(const Abc abc) {
switch (abc) {
case AAA:
return "AAA";
case BBB:
return "BBB";
default:
return "CCC";
}
}
};
int main(int argc, char const* argv[]) {
Abc a = AAA;
cout << EnumToStringUtil::ConvertAbcToString(a) << endl;
}