Virtual table is exactly created for which class in Diamond Inheritance?
<p>Consider the below code snippet:</p>

<pre><code>class A
{
};

class B:public virtual A
{
};

class C:public virtual A
{
};

class D:public B,public C
{
};

int main()
{
    cout&lt;&lt;sizeof(A)&lt;&lt;" "&lt;&lt;sizeof(B)&lt;&lt;" "&lt;&lt;sizeof(C)&lt;&lt;" "&lt;&lt;sizeof(D));
    return 0;
}
</code></pre>

<p>I am getting the <a href="http://ideone.com/U362b" rel="nofollow">output</a> as:</p>

<pre><code>1 4 4 8
</code></pre>

<p>The size of classes <code>B</code> and <code>C</code> is 4 bytes due to the creation of <code>vptr</code>. Does it mean that <code>virtual table</code> is created for classes <code>B</code> and <code>C</code>? What about <code>A</code>?</p>

<p>In general, <strong>for which classes the compiler exactly creates the <code>virtual table</code> in diamond inheritance?</strong><br>
<strong>Is the decision for creating virtual table is compiler specific?</strong></p>

<p>Please answer in the context of the above example or any other better example.</p>
