Virtual inheritance and parametrized constructors
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3524019/default-constructor-and-virtual-inheritance">Default constructor and virtual inheritance</a>  </p>
</blockquote>



<pre><code>class Base
{
private:
    int number;
protected:
    Base(int n) : number(n) {}
public:
    virtual void write() {cout &lt;&lt; number;}     
};

class Derived1 : virtual public Base
{
private:
    int number;
protected:
    Derived1(int n, int n2) : Base(n), number(n2) {}
public:
    virtual void write() {Base::write(); cout &lt;&lt; number;}
};

class Derived2 : virtual public Base
{
private:
    int number;
protected:
    Derived2(int n, int n2) : Base(n), number(n2) {}
public:
    virtual void write() {Base::write(); cout &lt;&lt; number;}
};

class Problematic : public Derived1, public Derived2
{
private:
    int number;
public:
    Problematic(int n, int n2, int n3, int n4) : Derived1(n, n2), Derived2(n, n3), number(n4) {}
    virtual void write() {Derived1::write(); Derived2::write(); cout &lt;&lt; number;}
};

int main()
{
    Base* obj = new Problematic(1, 2, 3, 4);
    obj-&gt;write();
}
</code></pre>

<p>In other words:</p>

<pre><code>Base
| \
|  \
|   \
|    \
D1   D2
|    /
|   /
|  /
| /
Problematic
</code></pre>

<p>I'm trying to get "1 2 1 3 4" on the output. The compiler, however, keeps complaining that I need a parameterless constructor in Base, but when I add one, the "1" turns to garbage. Any ideas on how to approach it? Is it even possible to solve the diamond pattern using a parametrized constructor?</p>
