-
COM: release-function
Hello everybody!
I've just tried to do my first steps under COM and by doing that I've also read about the release()-function! And following this there was some sample-code in my book:
DWORD CSpaceship::XMotion::Release()
{
METHOD_PROLOGUE(CSpaceship,Motion)
if (pThis->m_dwRef == 0)
return 0;
if (-pThis->m_dwRef == 0) {
delete pThis;
return 0;
}
return pthis->m_dwRef;
}
And I didn't understand the second if-construct with the minus in front of the pThis!
Can anyone tell, what this minus in this case does and whats the difference between the two if-constructs?
Thanks for helping me!
Bye, Zechasso
-
The second if must must read --pThis->m_dwRef
(two minus signs) thus decrementing the ref-counter!
Once the references are down to zero, the object is deleted!
-
thank you
Just at this minute I've thought the same!
But thank for your help!
Ciao, Zechasso