Sign in to follow this  

inheritance & destructors, virtual destructor?

This topic is 3592 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 get the warning "deletion of pointer to incomplete type 'windows_gui'; no destructor called" and i notice the memory leak and improper shutdown. I decided to try typecasting the variable to the original class just for a test, still no luck. the destructor doesnt happen. I -think- i have 2 options, have a collection for every type (windows_gui, windows_guiText, etc). and the 2nd is using windows_gui and having a virtual destructor? i think having a virtual destructor is easier. i put destructor on my class(es) destructor and still no luck. How do i do make one properly?

Share this post


Link to post
Share on other sites
You do realise that i have no idea what you are talking about since i do not have access to your class design or code. What does windows_gui inherit from? If you delete a base class pointer pointing to a extended class, it will not call the extended class destructor unless the base class destructor is virtual.

Share this post


Link to post
Share on other sites
The warning tells you exactly what's happening. You're deleting a pointer to an incomplete type. An incomplete type is a type that the compiler doesn't know the definition of; for example, if you only have a forward declaration for the type. Solution: in the file that's giving you the error, include the header that defines the windows_gui type.

Share this post


Link to post
Share on other sites
got it!
a silly mistake. I thought i made the destructor virtual but after reading GamerSg i tried it again and it work.

i also thought my test would work since the definition is somewhere in the build (i am able to use new with it...) but it only works when the entire class is in there.

it works perfectly now. It sucks that iask cause i pretty much knew the answer before posting, i didnt double check >_<

Share this post


Link to post
Share on other sites

This topic is 3592 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this