title: Using binary flags to represent states, options, etc
body: <p>If I wanted to represent states or options or something similar using binary "flags" so that I could pass them and store them to an object like <code>OPTION1 | OPTION2</code> where <code>OPTION1</code> is 0001 and <code>OPTION2</code> is 0010, so that what gets passed is 0011, representing a mix of the options.</p>
  
  <p>How would I do this in C++? I was thinking something like</p>
  
  <pre><code>enum Option {
      Option_1 = 0x01,
      Option_2 = 0x02,
      Option_3 = 0x04,
      //...
  }
  
  void doSomething(Option options) {
      //...
  }
  
  int main() {
      doSomething(Option_1|Option_2);
  }
  </code></pre>
  
  <p>But then ideally, <code>doSomething</code> knows how to interpret the given Option.</p>
  
  <p>Am I on the right track? Is there a better way? </p>
  
  <p><strong>Update</strong></p>
  
  <p>And wouldn't I have to define an <code>Option</code> for every possible combination, also?</p>