You clear the vector when you want to continue to use the object for other purposes. You can clear the object and then fill it again. If you destroy the object, it is gone and you would have to construct a new one. As jsmith indicates you never call the destructor explicitly. The destructor is called when a stack allocated object goes out of scope at the end of a block or when you explicitly delete the object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
void function()
{
std::vector<int> myArray;
{
// fill the array with 10 values.
myArray.push_back(i);
}
// The object still exists. You simply cleared it. You can still use
// myArray to fill it with new values if you would like.
myArray.clear();
// When function exits destructor for myArray is called automatically.
// if myArray had been allocated using "new std::vector<int>"
// you'd have to call "delete myArray" when ready to call the destructor.
}