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

Is there an open source WebSockets (JavaScript) XMPP library? -

java - Is there an object like a "Set" that can contain only unique string values, but also contain a count on the number of occurrences of the string value? -

iphone - How do I make a UIPickerView in a UIActionSheet -