Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

how to clear vector c++

// std::vector::clear removes all elements from the vector
std::vector<int> vec { 1, 2, 3 };
vec.clear();  // empty vector
// std::vector::erace remove element(elements) from the vector
std::vector<int> vec { 1, 2, 3 };
vec.erace(vec.begin());  // { 2, 3 }
vec.erace(vec.begin(), vec.end());  // empty vector
 
PREVIOUS NEXT
Tagged: #clear #vector
ADD COMMENT
Topic
Name
1+3 =