3 ms·
> 'delete ptr' in a destructor, not 'delete this' in a Release function That approach requires client and server to be written in the same language, use the sa
by Const-me 3y ago
> 'delete ptr' in a destructor, not 'delete this' in a Release function
That approach requires client and server to be written in the same language, use the same memory allocator, and same compiler. For COM objects, often all of these are false.
For example, C#, PowerShell or VBScript code can call IUnknown.Release() method of C++ implemented COM objects, which will cause C++ code to deallocate the memory. However, these higher level languages can’t directly delete C++ objects: they know nothing about C++ runtime, or C runtime.