J
jrwats
So a common pattern in C++ to stop classes from inheriting from a
class is:
class NoInheritBase
{
private:
friend class NoClassesCanInheritFromMe;
NoInheritBase(){ }
};
class NoClassesCanInheritFromMe: virtual NoInherit
{
};
class SomeClass : public NoClassesCanInheritFromMe // Ok, but you
can't call SomeClass' constructor
{
};
int main()
{
//class SomeClass; Compiler error!
}
Does anyone know of a generic (possibly templated) way to make
NoInheritBase such that it does not need to know about
NoClassesCanInheritFromMe?
class is:
class NoInheritBase
{
private:
friend class NoClassesCanInheritFromMe;
NoInheritBase(){ }
};
class NoClassesCanInheritFromMe: virtual NoInherit
{
};
class SomeClass : public NoClassesCanInheritFromMe // Ok, but you
can't call SomeClass' constructor
{
};
int main()
{
//class SomeClass; Compiler error!
}
Does anyone know of a generic (possibly templated) way to make
NoInheritBase such that it does not need to know about
NoClassesCanInheritFromMe?