title: The process of creating a class that involves virtual inheritance
body: <p>In many tutorials describing the usage of virtual base classes (usually used to solve the diamond problem), they often have a code similar to the design of this structure:</p>
  
  <pre><code>class Animal
  {
  public:
      Animal()
      {
          cout &lt;&lt; "Creating Animal\n";
      }
  };
  
  ///////////////////////////
  
  class FourLegs : virtual public Animal
  {
  public:
      FourLegs()
      {
          cout &lt;&lt; "Creating FourLegs\n";
      }
  };
  
  ///////////////////////////
  
  class Mammal : virtual public Animal
  {
  public:
      Mammal()
      {
          cout &lt;&lt; "Creating Mammal\n";
      }
  };
  
  ///////////////////////////
  
  class Fox : public FourLegs, public Mammal
  {
  public:
      Fox()
      {
          cout &lt;&lt; "Creating Fox\n";
      }
  };
  </code></pre>
  
  <p>When I create an instance of Fox, I get the expected output, only one Animal created:</p>
  
  <pre><code>Creating Animal
  Creating FourLegs
  Creating Mammal
  Creating Fox
  </code></pre>
  
  <p>As you can see, I have the two tier-2 classes inherit virtually. Now, if only <i>one</i> tier-2 class is inherited virtually, and the other is inherited just publicly, interesting outputs can occur. For example, if if FourLegs is inherited public and Mammal is inherited virtual public, this is the output:</p>
  
  <pre><code>Creating Animal
  Creating Animal
  Creating FourLegs
  Creating Mammal
  Creating Fox
  </code></pre>
  
  <p>This is strange and brings up the question: <strong>What is the complete process of creating a class that involves virtual inheritance somewhere in the inheritance tree?</strong></p>
  
  <p>On the other hand, if I FourLegs if inherited virtual public, and Mammal is inherited public, then the output is as just normal (as if nothing was inherited virtual public):</p>
  
  <pre><code>Creating Animal
  Creating FourLegs
  Creating Animal
  Creating Mammal
  Creating Fox
  </code></pre>