Original Post
I am having a little trouble with my vector and deleting items from it. For my vector, I am using this: std::vector structs; Now, I want to loop through each member of the vector and erase each one that has a certain member variable set. This is what I have so far: Now, whenever I run this code, my debugger yells at me every time it hits the 4th line, something along the lines of invalid pointer access. Am I able to do what I am doing? I am quite sure that the objects that the vector is pointing to do exist. Thanks
std::vector<STRUCT*>::iterator i;
for( i = structs.begin(); i != structs.end(); i++ )
{
if( ( *i )->bShouldBeCleared )
structs.erase( i );
}