title: How to simplify multiple if-else-if statements in c++
body: <p>Suppose I have four functions for four cases:</p>
  
  <pre><code>void ac() {
   //do something
  }
  void ad() {
   //do something
  }
  void bc() {
   //do something
  }
  void bd() {
   //do something
  }
  
  void f(bool a, bool b, bool c, bool d) {
      if(a and c) {
          ac();
      }
      else if(a and d) {
          ad();
      }
      else if(b and c) {
          bc();
      }
      else if(b and d){
          bd();
      }
      else {
              throw 1;
      }
  }
  </code></pre>
  
  <p>For the 2 by 2 situation it's quite simple, but in more complex situations, 
      this can get very tedious. Is there a way to simplify this?</p>