Answer to Question #534 in C++ for Albert
Is it possible for dynamically allocated objects to be automatically deleted when you exit out of scope?
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.
No comments. Be first!