Archived

This topic is now archived and is closed to further replies.

void deconstructors

This topic is 5669 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 using void* to store data for an object that can change type in a program I''m working on. This includes some types with deconstructors. Can I just cast the variable to that type when deleting it, or is there some other process needed to destroy it? Thanks!

Share this post


Link to post
Share on other sites
Yes, you can cast void pointers to other pointer types.

However, void pointers often can be replaced with pointers to non-void data. There''s inheritance and templates, for instance. Void pointers have their uses, but if you are using them to store types with constructors/destructors, it''s better to avoid them.

Share this post


Link to post
Share on other sites