title: Calling a function of sister class C++
body: <p>Consider the following code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class A
  {
  public:
      virtual void f() = 0;
      virtual void g() = 0;
  };
  
  class B : virtual public A
  {
  public:
      virtual void f()
      {
          g();
      }
  };
  
  class C : virtual public A
  {
  public:
      virtual void g()
      {
          std::cout &lt;&lt; "C::g" &lt;&lt; std::endl;
      }
  };
  
  class D : public C, public B
  {
  };
  
  int main()
  {
      B* b = new D;
      b-&gt;f();
  }
  </code></pre>
  
  <p>The output of the following program is <code>C::g</code>.</p>
  
  <p>How does the compiler invoke a function of a sister class of class B??</p>