Search Results

Search found 1 results on 1 pages for 'bo23'.

Page 1/1 | 1 

  • Empty vector of type <stuff*>

    - by bo23
    I have a vector populated with objects: std::vector<Stuff*> stuffVector; and am trying to delete all elements of it using a cleanup function void CleanUp() { for (std::vector<Stuff*>::size_type i = 0 ; i < stuffVector.size() ; i++) { stuffVector.erase(stuffVector.begin()+i); } cout << stuffVector.size() << endl; if (stuffVector.size() == 0) cout << "Vector Emptied" << endl; } This always reports back with a size of however many objects are in the vector, and doesn't actually seem to delete anything at all. It's odd as a similar function works elsewhere to delete a specific object from the vector: void DestroyStuff() { if (stuffVector.size() > 1) { for (std::vector<Stuff*>::size_type i = 0 ; i < stuffVector.size() ; i++ ) { if(stuffVector[i]->CanDestroy()) { stuffVector.erase (stuffVector.begin()+i); } } } } The above works fine, but CleanUp() does not. Why might this be happening?

    Read the article

1