title: What type do I use in the constructor to initialize a member variable defined by a nameless enum?
body: <p>I have a struct containing a member variable <code>category</code> which I guess is of type &quot;nameless enum&quot;.</p>
  <pre><code>struct Token {
      Token();
      enum {
              NUMBER, VARIABLE, PLUS, MINUS, PRODUCT, DIVISION, POWER, SIN, COS
      } category;
      union { 
          char variable;
          double number;
      };
  };
  </code></pre>
  <p>As you can see I also have a constructor <code>Token()</code>. I would like to be able to use the constructor like this:</p>
  <pre><code>Token my_token(Token::NUMBER, 5);
  </code></pre>
  <p>Instead of doing something like this:</p>
  <pre><code>Token my_token;
  my_token.category = Token::NUMBER;
  my_token.number = 5;
  </code></pre>
  <p>My question now is, what types do I use for the constructor? I tried something like this:</p>
  <pre><code>//declaration
  Token(int category, int number);
  
  //definition
  Token(int category, int number) : category(category), number(number) {}
  </code></pre>
  <p>But then when I try to initialize an object of the Token struct I get:<br />
  <code>error: invalid conversion from ‘int’ to ‘Token::&lt;unnamed enum&gt;’ [-fpermissive]</code></p>
  <p>I would like to keep the enum inside of the struct, some help with what type to use to initialize the union would also be appreciated.</p>