'identifier1' : direct base 'identifier2' is inaccessible; already a base of 'identifier3'
The specified derived class (identifier1) was derived from a direct base class (identifier3) that was already a base class of the derived class (identifier2).
A class (or structure) cannot use the same class more than once if it is already a direct base class in the hierarchy (a class mentioned in the list of base classes for the derived class). For example:
class A
{
public:
A() {;}
};
class B : public A
{
public:
B() {;}
};
class C : public B, virtual public A
// error: A is already a direct base class of B
{
public:
C() {;}
};
In order to use class A
as a base class of both B
and C
, it must be virtually inherited by each class. For example:
class A
{
public:
A() {;}
};
class B : virtual public A
{
public:
B() {;}
};
class C : public B, virtual public A
// ok: A is virtually inherited by both B and C
{
public:
C() {;}
};