title: Accessing to enum values by '::' in C++
body: <p>I have class like following:  </p>
  
  <pre><code>class Car  
  {  
  public:  
      Car();  
      // Some functions and members and &lt;b&gt;enums&lt;/b&gt;  
      enum Color
      {
          Red,
          Blue,
          Black
      };  
      Color getColor();
      void setColor(Color);  
  private:  
      Color myColor;
  }
  </code></pre>
  
  <p>I want to:</p>
  
  <ol>
  <li>access to <code>Color</code> values as <code>Color::Red</code>. It is really hardly to understand code when <code>Car::Red</code> is used, when class have a lot enums, subclasses etc.  </li>
  <li>use type <code>Color</code> as function argument or return value  </li>
  <li>use variable type <code>Color</code> in <code>switch</code></li>
  </ol>
  
  <p>I know 3 partial solutions:  </p>
  
  <ol>
  <li>Using embedded class <code>Color</code> and enum in it  </li>
  <li>Using embedded namespace <code>Color</code> and enum in it  </li>
  <li>Using <code>enum class</code>  </li>
  </ol>
  
  <p>1 and 2 solutions solves a <code>Color::Red</code> accession problem, but I can't use functions like <code>Color getColor()</code> and <code>void setColor(Color)</code>.</p>
  
  <p>3 solution has a problem: VS2010 doen't support <code>enum class</code>. GCC v.4.1.2 doesn't support it too. I don't know about later versions of gcc.  </p>
  
  <p>Yes, I'm working on cross-platform project.<br>
  I have found <a href="http://www.gamedev.net/topic/299161-c-using--to-get-enum-members/page__view__findpost__p__2898948" rel="noreferrer">this</a> solution, but it seems ... heavy.<br>
  I hope somebody can help me here :)</p>