I have a multimap from which I want to free the memory allocated to multimap.
I have posed a query related to this in one of the other question in Stackoverflow
Will this code free memory allocated for MULTIMAP? .
My question is that whether using an erase in multimap makes sure if all memory space allocated for multimap is freed ?
If you use a clear() (or erase() with begin() and end()), all memory for items That the multimap have allocated will be released.
This works perfectly well for say, stocking ints.
If you allocate memory and then stock pointers in a multimap, you’ll need to free that memory up yourself.
It works “as usual”, you allocate -> you free it up, for ints, chars and multimaps, it is up to them to free memory they have allocated.