title: How do I use an enum value in a switch statement in C++?
body: <p>I would like to use an <code>enum</code> value for a <code>switch</code> statement. Is it possible to use the <code>enum</code> values enclosed in <code>&quot;{}&quot;</code> as choices for the <code>switch()</code>&quot;?</p>
  <p>I know that <code>switch()</code> needs an <code>int</code>eger value in order to direct the flow of programming to the appropriate <code>case</code> number. If this is the case, do I just make a variable for each constant in the <code>enum</code> statement?</p>
  <p>I also want the user to be able to pick the choice and pass that choice to the <code>switch()</code> statement.</p>
  <p>For example:</p>
  <pre><code>cout &lt;&lt; &quot;1 - Easy, &quot;;
  cout &lt;&lt; &quot;2 - Medium, &quot;;
  cout &lt;&lt; &quot;3 - Hard: &quot;;
  
  enum myChoice { EASY = 1, MEDIUM = 2, HARD = 3 };
  
  cin &gt;&gt; ????
  
  switch(????)
  {
  case 1/EASY:  // (can I just type case EASY?)
      cout &lt;&lt; &quot;You picked easy!&quot;;
      break;
  
  case 2/MEDIUM:
      cout &lt;&lt; &quot;You picked medium!&quot;;
      break;
  
  case 3/HARD: // ..... (the same thing as case 2 except on hard.)
  
  default:
      return 0;
  }
  </code></pre>