Remove all even numbers from a vector.Example
vector
V.push_back(1);
V.push_back(4);
V.push_back(2);
V.push_back(8);
V.push_back(5);
V.push_back(7);
copy(V.begin(), V.end(), ostream_iterator
// The output is "1 4 2 8 5 7"
vector
V.erase(new_end, V.end()); [1]
copy(V.begin(), V.end(), ostream_iterator
// The output is "1 5 7".
Loading...