c++ virtual public inheritance init strange result?
<p>The output of the program below is:
5
5</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

struct A
{
public:
    int myInt;
    A(int n): myInt(n){}
    A(): myInt(5) {}
};


class B : virtual public A
{
public:
    B(int n):A(10) {}
    B():A(10) {}
};

class C : virtual public A
{
public:
    C(int n):A(3*n) {}
};

class D : public B, public C
{
public:
    D(int n=90) : C(2*n), B(n) {}
};

class E : public D
{
public:
    E(int n=20):D(n-1) {}
};

int main()
{
    D d(100);
    cout &lt;&lt; d.myInt &lt;&lt; endl;
    E e;
    cout &lt;&lt; e.myInt &lt;&lt; endl;
    return 0;
}
</code></pre>

<p>Consider the object <code>d</code>. From what I understand the inheritance is constructed based on the order of the inheritance list (rather than the initialization list) so <code>B</code> class is constructed first with the param <code>100</code> which goes to class <code>A</code> with the parameter <code>10</code>. So now <code>A</code> sets <code>myInt</code> to the value <code>10</code>. The same goes for Class <code>c</code> and because <code>myInt</code> is virtual then it is set to the number <code>600</code>. I never expected <code>5</code>. why is this happening? </p>
