# [C++] Direct base is inaccessible

This topic is 3616 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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. :)

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 11
• 13
• 86
• 11
• 10
• ### Forum Statistics

• Total Topics
632973
• Total Posts
3009614
• ### Who's Online (See full list)

There are no registered users currently online

×