About destruct function in COM
COM
2
Posts
2
Posters
0
Views
1
Watching
-
in a COM object,the class implement some interface can have a destruct function? when the destruct fuction is executed?
Yes it can. The destructor is called when you delete the object - if you use "new / delete" operators for dynamic allocated objects or when the object goes out of scope, for local objects.For example if you implement "Release" from IUnknown like this : ULONG MyObject::Release() { if( -- m_dwCount == 0 ) { delete this; //here } return m_dwCount; } the destructor will be called at "delete this".