if I 'new' something,I need to 'delete' it when it becomes of no use in order to
release main memory.
when it comes to STL container, should I do the deleting mannually?
or to the point,
can STL container automatically release the main memory allocated to it or not?
Good thing I understand nub. I think he means that if we do something like this:
1 2 3 4 5 6 7 8 9 10
#include <fstream>
int main(int argc, char ** argv)
{
//allocate memory on heap for new ofstream.
std::ofstream * bob = new std::ofstream;
//This will not delete itself. If you leave it, it will cause a memory leak. Therefore..
delete bob;
}
Same applies for containers. Sorry I couldn't give one for an actual container. But after this, I realized I've never used a pointer to a templated class or object and I actually don't know how. lol