title: C++ Call private / protected function of a common base class
body: <p>Is there a nice way to call <code>A::foo()</code> from <code>B::bar()</code> in the following sample?</p>
  
  <pre><code>class A {
  protected:
    void foo() {}
  };
  
  class B : public A {
  public:
    void bar(A&amp; a) { // edit: called with &amp;a != this
      a.foo(); // does not work
    }
  };
  </code></pre>
  
  <p>I can't think of anything other than declaring <code>B</code> to be a friend of <code>A</code>, but that could get pretty ugly with some more classes.</p>
  
  <p>Any ideas?</p>