Jump to content
  • Advertisement
Sign in to follow this  
Cybernator

[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.

If you intended to correct an error in the post then please contact us.

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

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!