|
-
December 8th, 2003, 06:03 AM
#1
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
-
December 8th, 2003, 07:28 AM
#2
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!
The Saviour of the World is a Penguin and Linus Torvalds is his Prophet.
-
December 8th, 2003, 07:36 AM
#3
thank you
Just at this minute I've thought the same!
But thank for your help!
Ciao, Zechasso
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|