Bind a char to an enum type

后端 未结 3 1805
死守一世寂寞
死守一世寂寞 2021-02-20 15:44

I have a piece of code pretty similar to this:

class someclass
{
public:
enum Section{START,MID,END};
vector
Full; void ex(){ for(int i=0;i<
3条回答
  •  青春惊慌失措
    2021-02-20 16:07

    In a situation like this you could be tricky and cast your chars.

    enum Section{
        START = (int)'S',
        MID   = (int)'M',
        END   = (int)'E'
    };
    
    ...
    
    inline char getChar(Section section)
    {
        return (char)section;
    }
    

提交回复
热议问题