The problem you have is temporary values and what happens to them:
I think this will be clear (I hope
The problem is that your are taking a copy of the value in the list. This does indeed correctly delete the object. BUT then you do v=0 rather
than
*vertexListIterator = 0 ; . Now you access the value in the list, which you have not erased, and then you access the memory area that you have deleted BUT that memory space is marked as deleted but is unlikely to have been over written so you get valid results. If you had done lots of other operations then you might get different results.
Note that if the list was just list<int> and the values were 1,2,3, you would not expect this to change the list:
for(list<int>::iterator ai=L.begin();ai!=L.end();++ai)
{
int x= *ai;
x=4; // This doesn't change anything in list
}
The normal process that would be not to use the temporary.
delete *vertexListIterator;
*vertexListIterator=0
Also please please don't use the C style casts, use a static_cast. That would remove any problems that might arise in-case the list turned out to be of a polymorphic class, and Vertex wasn't the base.
You use reinterpret_cast<long int> in the output of the pointer value to be printed.