Garmaine Staff asked 1 year ago

I know this is a simple question. But I want to cast enum value not red, blue but 0, 1, 2 etc to string. I want to see 0, 1, 2 as string. I am using c++ 14 compiler, any answer would be good.

#include <iostream>

int main()
{
    enum Color
    {
        red = 0,
        blue
    };

    Color color= Color::blue;

    std::string mystr = "I am super person my color enum value: ";
    mystr = mystr + color ;


    return 0;
}

Inother words I like to cast 0, 1, 2, as enum values to string. for concatenating with other strings