Is it possible for dynamically allocated objects to be automatically deleted when you exit out of scope?
1
Expert's answer
2010-08-04T11:10:56-0400
Technically, it is possible, but you will have to use tricks. You have to create a class that will encapsulate the dynamic object. In constructor you allocate memory for it, and in destructor you free it. If this object is non-trivial class and you want to be able to use the methods of this class via the class member's selector, you can overload the operator “->” and make sure that it returns an encapsulated pointer.
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment