Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualCornstalks

Posted 04 April 2013 - 08:49 AM

 Does an interface in c++ really need an virtual destructor or is it some compiler-setting or define I need to do?

Yes, it really does need it. Read this, then read this, and then probably read everything here. The problem, to say it concisely, is that without marking the destructor as "virtual" then when you delete an object, the destructors don't get properly called up/down the inheritance chain. This is only really a problem if you're using polymorphism and delete an object through a pointer to a base object.

 

And for what it's worth, your destructor isn't "pure virtual" (it's just virtual).


#1Cornstalks

Posted 04 April 2013 - 08:47 AM

 Does an interface in c++ really need an virtual destructor or is it some compiler-setting or define I need to do?

Yes, it really does need it. Read this, then read this, and then probably read everything here.

 

And for what it's worth, your destructor isn't "pure virtual" (it's just virtual).


PARTNERS