#define ENM \
E(AAA)\
E(BBB)
#define E(x) x,
enum {
ENM
};
#undef E
#define E(x) #x,
const char* strs[] = {
ENM
};
#undef E
int main() {
cout << AAA << endl; // 0
cout << strs[AAA] << endl; // AAA
return 0;
}
Happy Programming! I am a game programmer and this blog introduces technical issues, and my daily programming struggle against various jobs.
Wednesday, August 23, 2017
Enum with string
If you need enums and strings that are equivalent as that names, You can declare like this.
Subscribe to:
Post Comments (Atom)
It's magic! std::bind
'std::bind' is a powerful helper for working around 'std::function'. 'std::bind' makes a instance of 'std::fun...
No comments:
Post a Comment