I have an enum and i want to get those enum types in to string in Switch case conditions.
enum WeekEnum
{
Mon = 0;
Tue = 1;
Wed = 2;
}
std::string weekEnumToStr(int n)
{
std::string s("unknown");
switch (n)
{
case 0: { s = "Mon"; } break;
case 1: { s = "Tue"; } break;
case 2: { s = "Wed"; } break;
}
return s;
}
So in the above i am hardcoding the "Mon" instead is there a way that we get the enum type directly as a string. As currently if i am passing enum type inside switch case i am getting the id either 0 or 1 or 2 but i need Mon/Tue/Wed as a string