title: How can I output the value of an enum class in C++11
body: <p>How can I output the value of an <code>enum class</code> in C++11? In C++03 it's like this:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  enum A {
    a = 1,
    b = 69,
    c= 666
  };
  
  int main () {
    A a = A::c;
    cout &lt;&lt; a &lt;&lt; endl;
  }
  </code></pre>
  
  <p>in c++0x this code doesn't compile</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  enum class A {
    a = 1,
    b = 69,
    c= 666
  };
  
  int main () {
    A a = A::c;
    cout &lt;&lt; a &lt;&lt; endl;
  }
  
  
  prog.cpp:13:11: error: cannot bind 'std::ostream' lvalue to 'std::basic_ostream&lt;char&gt;&amp;&amp;'
  /usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/ostream:579:5: error:   initializing argument 1 of 'std::basic_ostream&lt;_CharT, _Traits&gt;&amp; std::operator&lt;&lt;(std::basic_ostream&lt;_CharT, _Traits&gt;&amp;&amp;, const _Tp&amp;) [with _CharT = char, _Traits = std::char_traits&lt;char&gt;, _Tp = A]'
  </code></pre>
  
  <p>compiled at <a href="https://ideone.com/" rel="noreferrer">Ideone.com</a></p>