Use templates to prevent memory leakageThis tip submitted by Kunal on 2005-01-27 23:01:00. It has been viewed 39278 times.
Rating of 5.6 with 183 votes
Make a class template to create an instance of a desired class and in the destructor of the class template, delete the item the pointer points to.
In this way, the programmer won't have to worry about freeing the memory.
Help your fellow programmers! Add a tip!