To avoid inheritance of class Base, I ran a test:
class non_inherit {
protected:
non_inherit(){}
};
class Base : virtual non_inherit{
public:
Base(){}
};
class Derived : public Base{
public:
Derived(){}
};
int main(){
Derived d;
return 0;
}
And it runs successfully with no errors. Since Base is privately inherited from non_inherit, the default constructor is supposed to be private for Derived, so how can Derived access the constructor of non_inherit?
I tried to call the c'tor of non_inherit explicitly in the c'tor of Derived, and it fails! So what did the compiler do to successfully create the object of Derived.