title: c++ switch vs. member function pointer vs. virtual inheritance
body: <p>I am trying to analyze the trade offs between various methods of achieving polymorphism. I need a list of objects with some similarities and some differences in member functions. The options I see are as follows:</p>
  
  <ol>
  <li>have a flag in each object, and a switch statement in each function.
  The value of the flag directs each object to its specific section of
  each function.</li>
  <li>have an array of member function pointers in the object, which are
  assigned upon construction. Then, I call that function pointer to
  get the correct member function.</li>
  <li>have an virtual base class with several derived classes. One
  drawback to this is that my list will now have to contain pointers,
  and not the objects themselves.</li>
  </ol>
  
  <p>My understanding is that the pointer lookups from the list in option 3 will take longer than the member function lookups of option 2 because of the guaranteed proximity of member functions.</p>
  
  <p>What are some of the benefits/drawbacks of these options? My priority is performance over readability. 
  Is there any other method for polymorphism?</p>