sizeof() problems with empty class inheritance
<pre><code>#include &lt;stdio.h&gt; 

class X 
{
};

class Y
{
     // long x; // case A)
     // X x;    // case B)
};

class Z : public Y, public X
{
};

int main() {
     Z z;
     printf("%d %d %d\n", 
        sizeof(Z), sizeof(Y), (char*)static_cast&lt;X*&gt;(&amp;z) - (char*)&amp;z);
     return 0;
}
</code></pre>

<p>Why is the output as follows after uncommenting either case A or case B:</p>

<p>A: <code>4 4 4</code><br>
B: <code>2 1 2</code></p>

<p>Why is <code>sizeof(Y) != sizeof(Z)</code> in case B), but is equal in case A). Can anyone explain?</p>
