title: How to access an C++11 enum class from another file?
body: <p>I have a header file that will eventually include more than one enum class. However, when I include the header file in another file and try to use the enum class, my program will not compile. For example:</p>
  
  <p>enums.h:</p>
  
  <pre><code>#ifndef ENUMS_H
  #define ENUMS_H
  
  enum class TokenType : char
  {
       IDEN,
       STRING,
       SEMICO
  };
  
  #endif
  </code></pre>
  
  <p>and main.cpp:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "enums.h"
  
  int main()
  {
       char token = TokenType::STRING; //Does not compile!
  }
  </code></pre>
  
  <p><strong>However, when I use a regular enum, it compiles correctly:</strong></p>
  
  <p>enums.h:</p>
  
  <pre><code>#ifndef ENUMS_H
  #define ENUMS_H
  
  enum TokenType : char
  {
       IDEN,
       STRING,
       SEMICO
  }
  
  #endif
  </code></pre>
  
  <p>and main.cpp:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "enums.h"
  
  int main()
  {
       char token = STRING; //This does compile!
  }
  </code></pre>
  
  <p>Does anyone know how to do this correctly? I've searched a lot and came up with nothing.</p>