vector::pop_back function


The pop_back function of vector removes the last element of the vector.

void pop_back();

Parameters:
none

Return type
none

This function will only decrease the size of the vector not the capacity of the vector.And after the function is called the data is lost forever.

Link:vector::insert function

Code example

vector<int> vec={ 12 , 23 , 4 } ;

vec.pop_back( ) ;

vec.reserve( 5 ) ;

for( auto elem:vec )
{
cout<< elem << ” “;
}

cout<< vec.size( ) << endl
<< vec.capacity( ) ;

Output

12 23
2
5

Link:vector::capacity function


 


Stop wasting time,earn money($$$) from your website-Join Now!