Where does the destructor code for things I have defined in an ATL COM object belong?
Should it go in ~MyComClass()
or in MyComClass::FinalRelease()
?
As long as FinalRelease
is in question, I assume your question is related to ATL.
In most cases you can clean things up in either of the two. FinalRelease
will be called immediately before the actual destructor. The important difference is that if you aggregate other objects, FinalRelease gives you a chance to clean the references and release dependencies before actual destructor of top level COM object class (esp. CComObject
) starts working.
That is, you clean things up in two steps, first references to aggregated objects in FinalRelease
and then other things in either FinalRelease
or destructor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With