Jump to content
  • Advertisement
Sign in to follow this  
Sc4Freak

C++ Multiple Inheritance with Pure Abstract Base Classes

This topic is 2547 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'm getting back into C++ after quite a lengthy dry spell and some of the language's idiosyncracies are escaping me for the moment. If I inherit from multiple base classes and get the "dreaded diamond", is virtual inheritance still necessary if all the base classes are pure abstract base classes ("interfaces")? Because all the base classes contain only pure virtual function definitions (and no other members), would virtual inheritance essentially be a no-op in this situation?


Share this post


Link to post
Share on other sites
Advertisement
Virtual inheritance is never a no-op. It always has some overhead. Whether or not you need virtual inheritance depends on how you use that base class. If you ever use dynamic_cast to the base, compare base pointers or other similar activities then you should probably use virtual inheritance.

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!