[C++] Direct base is inaccessible

Started by
-1 comments, last by Cybernator 15 years, 4 months ago
I've been experimenting with inheritance and stumbled upon the following issue. (Compiler used: Visual C++ 2008).
struct A {};
struct B : virtual public A {};
struct C : public A, public B {};
The compiler yields the following error: error C2584: 'C' : direct base 'A' is inaccessible; already a base of 'B'. I realize that access is ambiguous, and hence I need to qualify the symbols, but why is base A inaccessible? And now for something even weirder:
struct C : public B, public A {};
If I change the order of inheritance, it actually compiles. Only a warning is issued, which is perfectly clear. Is this a Visual C++ specific problem? Does order of inheritance imply semantic differences? Last but not least, I realize this class hierarchy is pointless. I'm merely curious, that's all. :)

This topic is closed to new replies.

Advertisement