Monday, March 31, 2014

Therefore, this object can not be allocated on the stack, that is, out of scope object still exists


Therefore, this object can not be allocated on the stack, that is, out of scope object still exists, there is no destruction. It can only be a static object, or a heap object. So the question again, catch statement in the client, the client in the end not to execute delete it? Customers do not know the object is static or heap objects. If you do delete, and the object is to throw an end static, objects on the heap is not assigned, perform delete, resulting in undefined behavior. If you do not perform delete, and the object is a heap object thrown side, resulting in a resource leak. Therefore, this approach is not feasible.


No comments:

Post a Comment