title: Using enums correctly C++
body: <p>I've been trying to learn how to use enums correctly in C++, and I can barely understand how to handle them. I made a simple program that changes traffic lights using enums and bitwise operations:</p>
  
  <pre><code>    #include &lt;iostream&gt;
  
  enum lights
  {
      green = 1,
      yellow = 2,
      red = 4,
      control = 7
  };
  
  std::string change_light (std::string choice)
  {
      lights light;
      int changed;
  
      if (choice == "yellow")
          light = yellow;
  
      else if (choice == "red")
          light = red;
  
      else if (choice == "green")
          light = green;
  
      changed = control &amp; light;
  
      if (changed == red)
          return "red";
  
      else if (changed == yellow)
          return "yellow";
  
      else if (changed == green)
          return "green";
  }
  
  int main()
  {   
      std::string choice = "";
  
      while (1)
      {
          std::cout &lt;&lt; "What light do you want to turn on?" &lt;&lt; std::endl;
          std::cin &gt;&gt; choice;
          std::cout &lt;&lt; "Changed to " &lt;&lt; change_light(choice) &lt;&lt; std::endl;
      }
  
      return 0;
  }
  </code></pre>
  
  <p>How do I improve that program while keeping the use of bitwise operations and enums? If you could show me how to improve it, it would greatly improve my understanding of how to use enums correctly.</p>
  
  <p>Thanks :D</p>