class ClassSealer {
private:
friend class Sealed;
ClassSealer() {}
};
class Sealed : public ClassSealer
{
// ...
};
class FailsToDerive : public Sealed
{
// This class is capable of being instantiated
};
The above fails to seal the class, but the following works, why?
class ClassSealer {
private:
friend class Sealed;
ClassSealer() {}
};
class Sealed : public virtual ClassSealer
{
// ...
};
class FailsToDerive : public Sealed
{
// Cannot be instantiated
};
What is happening here? What role does virtual inheritance does play here?