Derived to base class conversion
<p>How does the conversion between derived and base class internally occurs and how does compiler knows or does it store the size of object?</p>

<p>For example in the following:</p>

<pre><code>class A
{
public:
 A():x(2){};
private:
 int x;
};

class B : public A
{
public:
 B():A(),y(5){};
private:
 int y;
};

class C : public B
{
public:
 C():B(),z(9){};
private:
 int z;
};

int main()
{
   C *CObj = new C;
   B *pB = static_cast&lt;B*&gt;(CObj);
   delete CObj;
}
</code></pre>

<p><strong>Edit:</strong> It must have been this:</p>

<pre><code>B BObj = static_cast&lt;B&gt;(*CObj);
</code></pre>
