With
C++
you have to do some work (
C#
, for instance gently provides it).
Your best bet is (unfortunately, maybe...) a
std::map
.
enum Color
{
Red,
Green,
Blue
};
map<CString , Color> m;
m.insert(make_pair<CString, Color>(_T("Red"),Red));
m.insert(make_pair<CString, Color>(_T("Green"),Green));
m.insert(make_pair<CString, Color>(_T("Blue"),Blue));
Color c = m[_T("Green")];