how C++ ensures the concept of base class and derived class
<p>I would like to know how c++ ensures the concept layout in memory of these classes to support inheritance.</p>

<p>for example:</p>

<pre><code>class Base1
{

    public:
        void function1(){cout&lt;&lt;"Base1"};

};

class Base2
{

    public:
        void function2(){cout&lt;&lt;"Base2"};

};

class MDerived: Base1,Base2
{

    public:
        void function1(){cout&lt;&lt;"MDerived"};

};

void function(Base1 *b1)
{

    b1-&gt;function1();
}
</code></pre>

<p>So when I pass function an object of derived type the function should offset into the base1 class function and call it. How does C++ ensure such a layout.</p>
