One of the fundamental differences between C++ and the more modern and if I dare say popular programming languages such as Java and C#, is the lack of a garbage collector in C++. Often this is used as an example to portray how C++ has not kept up with the times and how code written with the language is a potential minefield for memory leaks. While the debate about the merits of one language over the other continues (and in all possibility would continue for many more years), there are a few steps one can take, as a programmer, that can pretty much minimize, if not eliminate, the chances of a memory leak. I would like to list some of the techniques that I have employed over the years and have worked for me pretty well. Use RAII Use objects to abstract concepts Use std::auto_ptr Turn on memory tagging Use std::vector<> to allocate memory Declare base class destructor as virtual Use RAII Use RAII (Resoure Acquisition Is Initialization) programming paradigm: Per...
mostly notes & some thoughts...