class Base
{
protected:
int myvar;
void useBaseVar()
{
cout << myvar << endl;
}
public:
Base() : myvar(0) {}
~Base() {}
};
class Level1 : public Base
{
private:
int myvar;
public:
Level1() : Base(), myvar(1) {}
~Level1() {}
void useMyVarLevel1()
{
useBaseVar();
}
};
class Level2 : public Level1
{
private:
int myvar;
public:
Level2() : Level1(), myvar(2) {}
~Level2() {}
void useMyVarLevel2()
{
useBaseVar();
useMyVarLevel1();
}
};
Level2 o;
o.useMyVarLevel2();