Should “delete this” be called from within a member method?

前端 未结 12 2030
醉酒成梦
醉酒成梦 2020-12-03 10:55

I was just reading this article and wanted SO folks advice:

Q: Should delete this; be called from within a member method?

12条回答
  •  广开言路
    2020-12-03 10:57

    You can do it, provided its the last element in a member function, and that after return you forget that object ever existed.... but yeah, like that article asks ... Why would you want to do this ? I don't know what the standard says, but it does give me a funny feeling :P

    I guess this is a bit like should you ever use a GOTO statement, and I personally use GOTO to clean up resources in C sometimes, especially under exceptional conditions.

    I wonder what the shared state implications are (fuzzy statement I know):P

提交回复
热议问题