class X {
public:
int i;
};
class Y : virtual public X {};
class Z : public Y, virtual public X {
public:
void f() {
cout << i;
}
};
Why in this type of inheritance is object X inside Z found in only 1 instance and there is no ambiguity but if i did public X there's ambiguity. Isnt declaring class as virtual only to say when something is derived from Z later on , Z shall share X among other classes that inherited X as virtual?