I work on C++, and I am using an number of hash maps in my code. The problem is that, erasing of all the map iterators does not work, I get segmentation faults. If I dont erase the iterators, then everything works fine. I am afraid if I do not erase the iterators after use then memory leak would happen, is that true ?
Also say if there is an iterator to a hash map then what is the difference between these terms -
map.erase(iter->first); and map.erase(iter);
which one shall I chose and why ? and what will happen if I do not erase the iterators.