Jump to content
  • Advertisement
Sign in to follow this  
Telastyn

Virtual Base Class Overhead?

This topic is 5427 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

so what you are doing is a little like the way unions (and RTTI engines) are normally done ... you store something, and something which tells you what it is ...

Share this post


Link to post
Share on other sites
Advertisement
Since I store the type with the void pointer it's easy to check.

The void pointer may be the source of your problems. Offset adjustments (including virtual base class lookup) aren't done when casting from void pointers.

Share this post


Link to post
Share on other sites
I can only imagine.

The storage container is my old 'naive newbie' implimentation of a heterogeneous linked list in C, which has grown and evolved as I've suffered by stobbornly putting off learning advanced C++ features and the STL.



enum types {NOTHING,PLAYER,EMPIRE,...};

class vine{
types type;
void *data;
vine *next;
vine *prev;

// manipulation functions
};



The previous implimentation of the GUI used a large switch statement to essentially change the cast based on the type field. Either inheritance or templates would've made that a lot more wieldy, but I was too headstrong to learn them.

Ideally I'll get to the STL next and finally remove my need for this, but for now it's nice and reliable.

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!