Erasing elements from a vector

后端 未结 5 708
萌比男神i
萌比男神i 2020-11-21 12:57

I want to clear a element from a vector using the erase method. But the problem here is that the element is not guaranteed to occur only once in the vector. It may be presen

5条回答
  •  攒了一身酷
    2020-11-21 13:38

    To erase 1st element you can use:

    vector mV{ 1, 2, 3, 4, 5 }; 
    vector::iterator it; 
    
    it = mV.begin(); 
    mV.erase(it); 
    

提交回复
热议问题