![]() |
Re: delete this; return ret;
Wenjie wrote:
> Hello, > > In other words, will //LABELED line > be executed? My confusion is that the > object should have been destructed at > that time. Yes it will. You can't access any member variables after delete this, but it doesn't affect the execution of the code. The only requirement of course is that your object is on the heap (constructed with new), not on the stack. In fact, when implementing a Microsoft COM component, it's the most common way of implementing IUnkown::Release(): STDMETHODIMP_(LONG) SomeObject::Release() { InternlockedDecrement(&m_nRef); if( m_nRef == 0 ) { delete this; return 0; // can't access m_nRef anymore } else return m_nRef; } -- Unforgiven "Not only do I not know the answer I don't even know what the question is" My world - Metallica |
| All times are GMT. The time now is 02:19 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.