Jump to content
  • Advertisement


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


delete derived class with base class pointer

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

hi when i create a derived class and store the pointer of the new created class in a base class pointer, can i delete the class with this pointer? here some code to show what i mean: class BaseClass { ... }; class DerivedClass : public BaseClass { ... }; BaseClass *pBaseClass = new DerivedClass //do something delete BaseClass; after some tests i found out that only the destructor of A is called after deleting this pointer. does this mean only a part (the BaseClass part) of class B is deleted? is there another way to delete such pointer without cast the pointer back? accelerate your pc with 9.81 m/s²

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!