sealfin
2006.12.29, 09:09 AM
Greetings, I currently have some code in which almost every class needs to privately inherit a global parent class, and I've hit a problem when class A inherits the global parent, class B likewise inherits that global parent, and class B inherits class A; perhaps code will make more sense...
class GlobalParent
{
public:
void Say( void ) { printf( "sealfin" ); return; };
};
class Parent : private GlobalParent
{
};
class Child : private GlobalParent, private Parent
{
};
warning: direct base `GlobalParent' inaccessible in `Child' due to ambiguity
I thought that this wouldn't pose a problem, as the GlobalParent inherited by Parent should be hidden from/inaccessible to Child; except that I've obviously misunderstood the scope rules in C++, and Child is seeing both the GlobalParent it inherits, and the GlobalParent inherited by Parent, which should be hidden/private...
Any suggestions as to how to fix this?
class GlobalParent
{
public:
void Say( void ) { printf( "sealfin" ); return; };
};
class Parent : private GlobalParent
{
};
class Child : private GlobalParent, private Parent
{
};
warning: direct base `GlobalParent' inaccessible in `Child' due to ambiguity
I thought that this wouldn't pose a problem, as the GlobalParent inherited by Parent should be hidden from/inaccessible to Child; except that I've obviously misunderstood the scope rules in C++, and Child is seeing both the GlobalParent it inherits, and the GlobalParent inherited by Parent, which should be hidden/private...
Any suggestions as to how to fix this?