You are creating a
CTest
instance on the stack and trying to delete it aftwerwards. That will of course crash because you can only delete objects that has been allocated on the heap using
new
.
So you would probably want to do something like this (depending on the type of the second
std::pair
element):
delete it->second;
Note that there is no need to check for
NULL
because
delete
allows passing it (does nothing).