Managing memory of polymorphic timed events with DLL

Posted by Milo on Stack Overflow See other posts from Stack Overflow or by Milo
Published on 2011-01-10T06:50:30Z Indexed on 2011/01/10 6:53 UTC
Read the original article Hit count: 170

Filed under:
|

Here is my issue.

My Gui library that I made supports timed events. Basically, I have a class called TimedEvent which users inherit from. They then do:

addTimedEvent(new DerivedTimedEvent(...));

However given the nature of timed events, I manage the memory afterwards.

So when the timed event has done its thing, my library calls delete on it. Although it runs fine, that is because the exe and the library were both built with msvc 2008. I think I might have trouble if I have 2 versions of the runtime, one for the lib, and one for the exe.

What can I do to fix this? I can't create a factory because the derived type is on the exe side of things. I also cannot ask the user to call delete since they might not have a way to keep track of time, or know if the event was delayed for whatever reason.

Thanks

© Stack Overflow or respective owner

Related posts about c++

Related posts about dll