I'm dealing with a map of vectors, and I'm making sure I clean up all the memory used. So, what exactly is the best way to handle this?
One person said to use clear() on each vector in the map and then use clear() on the map, but I don't think that deallocates the memory? Is that how I should handle this or is there another way?
Here's the part of my code I'm worried about.
main()
{ map <int, vector<string> > word;
map <int, vector<string> >::iterator it;
while (getline(cin, info) && info != "")
{ if ( isInVec(word[info.length()], info) == false)
word[info.length()].push_back(info); }
for ( it=word.begin() ; it != word.end(); it++ )
{ sort (word[(*it).first].begin(), word[(*it).first].end()); }
echoMap (word);
cout << endl;
system("pause");
return 0;
}