Diamond problem
<p>I was going through the diamond problem and thought will work on various scenarios. And this is one among them which I was working on.</p>

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

    public:
    int mainbase;
    MainBase(int i):mainbase(i){}
    void geta()
    {
        cout&lt;&lt;"mainbase"&lt;&lt;mainbase&lt;&lt;endl;
    }
};
class Derived1: public MainBase{

    public:
    int derived1;
    int mainbase;
    Derived1(int i):MainBase(i),derived1(i) {mainbase = 1;}
    public:
    void getderived1()
    {
        cout&lt;&lt;"derived1"&lt;&lt;derived1&lt;&lt;endl;
    }

};
class Derived2: public MainBase{

    public:
    int derived2;
    int mainbase;
    Derived2(int i):MainBase(i),derived2(i){mainbase = 2;}
    public:
    void getderived2()
    {
        cout&lt;&lt;"derived2"&lt;&lt;derived2&lt;&lt;endl;
    }
};
class Diamond: public Derived1, public Derived2{

    public:
    int diamond;
    int mainbase;
    Diamond(int i,int j, int x):Derived1(j),Derived2(x),diamond(i){mainbase=3;}
    public:
    void getdiamond()
    {
        cout&lt;&lt;"diamond"&lt;&lt;diamond&lt;&lt;endl;
    }
};
int main()
{
    Diamond d(4,5,6);
//    cout&lt;&lt; d.MainBase::mainbase;
    cout&lt;&lt;"tested"&lt;&lt;endl;
    cout&lt;&lt;d.mainbase;
    cout&lt;&lt;d.Derived2::mainbase&lt;&lt;endl;
    cout&lt;&lt;d.Derived1::mainbase&lt;&lt;endl;
    /*cout&lt;&lt;d.Derived2::MainBase::mainbase&lt;&lt;endl;
    cout&lt;&lt;d.Derived1::MainBase::mainbase&lt;&lt;endl;*/
}
</code></pre>

<p>I am now wondering how to I access MainBase class mainbase variable? Any inputs.</p>
