clear vs erase vector c 2b 2b

Solutions on MaxInterview for clear vs erase vector c 2b 2b by the best coders in the world

showing results for - "clear vs erase vector c 2b 2b"
Braylon
23 Jan 2016
1//Syntax
2vectorname.clear()
3vectorname.erase(startingposition, endingposition)
4  
5clear() removes all the elements from a vector container, thus making its 
6size 0. All the elements of the vector are removed using clear() function. 
7  
8erase() function, on the other hand, is used to remove specific elements from 
9the container or a range of elements from the container, thus reducing its
10size by the number of elements removed.
11