c++ - Should "delete this" be called from within a member method? -


I was just reading it and would like people's advice:

question: what it Should be removed; Can the member be called from within the law? Usually this is a bad idea, but it is sometimes useful.

It is completely safe until you use any member variables after deletion, and as long as the client calls this method, it can remove the object.

> When this is useful, then there is a good example of if your class counts the reference:

  zero referee () {m_References ++; } Zero Deref () {m_References--; If (m_References == 0) {delete it; }}  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -