I cannot figure out what would happen in the following scenario:
class MBase {
public:
MBase(int) {}
virtual char* vf() const = 0;
virtual ~MBase() {}
};
class D1 : public MBase { //NOT VIRTUAL!!!
public:
D1() : MBase(1) {}
char* vf() const { return "D1"; }
};
class D2 : virtual public MBase {
public:
D2() : MBase(2) {}
char* vf() const { return "D2"; }
};
class Bottom : public D1, public D2 {
public:
char* vf() const { return "Bottom"; }
}
Base* b = new Bottom();
In the original definition of the diamond both D1 and D2 were inheriting virtually from MBase, but here only one is. Would we still have two separate subobjects in Bottom object and therefore, the last line will not compile as compiler won't know which subobject to use?