title: C++ enum from char
body: <p>Ok, I'm new at C++.  I got Bjarne's book, and I'm trying to follow the calculator code.</p>
  
  <p>However, the compiler is spitting out an error about this section:</p>
  
  <pre><code>token_value get_token()
  {
      char ch;
  
      do {        // skip whitespace except '\n'
          if(!std::cin.get(ch)) return curr_tok = END;
      } while (ch!='\n' &amp;&amp; isspace(ch));
  
      switch (ch) {
          case ';':
          case '\n':
              std::cin &gt;&gt; WS;      // skip whitespace
              return curr_tok=PRINT;
          case '*':
          case '/':
          case '+':
          case '-':
          case '(':
          case ')':
          case '=':
              return curr_tok=ch;
          case '0': case '1': case '2': case '3': case '4': case '5':
          case '6': case '7': case '8': case '9': case '.':
              std::cin.putback(ch);
              std::cin &gt;&gt; number_value;
              return curr_tok=NUMBER;
          default:            // NAME, NAME=, or error
              if (isalpha(ch)) {
                  char* p = name_string;
                  *p++ = ch;
                  while (std::cin.get(ch) &amp;&amp; isalnum(ch)) *p++ = ch;
                  std::cin.putback(ch);
                  *p = 0;
                  return curr_tok=NAME;
              }
              error("bad token");
              return curr_tok=PRINT;
  }
  </code></pre>
  
  <p>The error it's spitting out is this:</p>
  
  <pre><code>calc.cpp:42: error: invalid conversion from ‘char’ to ‘token_value’
  </code></pre>
  
  <p><code>token_value</code> is an enum that looks like:</p>
  
  <pre><code>enum token_value {
      NAME,       NUMBER,     END,
      PLUS='+',   MINUS='-',  MUL='*',  DIV='/',
      PRINT=';',  ASSIGN='=', LP='(',   RP=')'
  };
  token_value curr_tok;
  </code></pre>
  
  <p>My question is, how do I convert ch (from cin), to the associated enum value?</p>