Export (0) Print
Expand All
Expand Minimize

Compiler Error C2584

'Class' : direct base 'Base2' is inaccessible; already a base of 'Base1'

Class already derives directly from Base1. Base2 also derives from Base1. Class cannot derive from Base2 because that would mean inheriting (indirectly) from Base1 again, which is not legal because Base1 is already a direct base class.

The following sample generates C2584.

// C2584.cpp
// compile with: /c
struct A1 {
   virtual int MyFunction();
};

struct A2 {
    virtual int MyFunction();
};

struct B1: public virtual A1, virtual A2 {
    virtual int MyFunction();
};

struct B2: public virtual A2, virtual A1 {
    virtual int MyFunction();
};

struct C: virtual B1, B2 {
    virtual int MyFunction();
};

struct Z : virtual B2, virtual C {   // C2584
// try the following line insted
// struct Z : virtual C {
    virtual int MyFunction();
};

Community Additions

ADD
Show:
© 2014 Microsoft