Class memory layout with inheritance from POD and from Neither Trivial or Standard Layout classes
<p>I'm trying to understand memory layout in C++. I've done some research on the subject, but I haven't been able to find an answer for these two following scenarios and was hoping you could help me.</p>

<p>First scenario:</p>

<pre><code>class A
{
public:
  int a1;
};

class B
{
public:
  virtual int B_virt();
};

class C: public A, public B
{
public:
  int c1;
};
</code></pre>

<p>Here's my expected memory layout for class C:</p>

<pre><code>class C size(12):
    +---
    | +--- (base class A)
 0  | | a1
    | +---
    | +--- (base class B)
 4  | | {vfptr}
    | +---
 8  | c1
    +---
</code></pre>

<p>First of all, is the memory layout above correct? Or Is a vfptr placed at position 0 (as part of class C) because it inherits from a class with a virtual function member.</p>

<p>Second scenario:</p>

<pre><code>class D: public A, public B
{
public:
  int B_virt();
};

class D size(8):
    +---
    | +--- (base class A)
 0  | | a1
    | +---
    | +--- (base class B)
 4  | | {vfptr}
    | +---
    +---
</code></pre>

<p>Is this correct? If not, is it because the overridden B_virt is implicitly a virtual function? What if B_virt was pure virtual in class B?</p>
