C
Chad E. Dollins
I would like to know how to remove an element from a vector. The following
give a segmentation fault perhaps someone can give me a proper explanation
why:
vector<T> * myCon;
//...some code that adds T to the container
vector<T>::iterator p1;
for(p1 = myCon->begin();p1 != myCon->end();++p1)
myCon->erase(*p1);
This may have syntax errors but the orignal code does not.
when erase is called on a seg fault happens. T has a default destructor.
Thanks,
--Chad
give a segmentation fault perhaps someone can give me a proper explanation
why:
vector<T> * myCon;
//...some code that adds T to the container
vector<T>::iterator p1;
for(p1 = myCon->begin();p1 != myCon->end();++p1)
myCon->erase(*p1);
This may have syntax errors but the orignal code does not.
when erase is called on a seg fault happens. T has a default destructor.
Thanks,
--Chad