title: Pass parent class reference as argument in derived class in C++
body: <p>I'm new to C++ and am trying to achieve the following design.</p>
  
  <pre><code>class A { do (); doMore (); } // abstract
  class B { do (); doMore (); } // abstract
  
  class X : public A, public B // Also abstract
  {        
      foo() {
          // common code
          A::do();
          A::doMore();
      }
      bar() {
          // common code
          B::do();
          B::doMore();
      }
  }
  </code></pre>
  
  <p>Both A and B provide implementations of <code>do()</code> and <code>doMore()</code>.
  How can I extract the common code that the new function takes an arg that calls the method in the correct parent class?</p>
  
  <p>Something like</p>
  
  <pre><code>X::newMethod(arg_that_indicates_parent_class) {
      // common code
      arg_that_indicates_parent_class::do();
      arg_that_indicates_parent_class::doMore();
  }
  </code></pre>
  
  <p>Then call it like so</p>
  
  <pre><code>newMethod(pass_A_somehow);
  newMethod(pass_B_somehow);
  </code></pre>
  
  <p>Looks like runtime polymorphism, but not quite (or is it?)... as it is within a child class... </p>
  
  <p>Is this design itself just trash and there is a better way to achieve this?</p>