Export (0) Print
Expand All
0 out of 2 rated this helpful - Rate this topic

vector::pop_back

Deletes the element at the end of the vector.

void pop_back( );

Example

// vector_pop_back.cpp
// compile with: /EHsc
#include <vector>
#include <iostream>

int main( )
{
   using namespace std;   
   vector <int> v1;
   
   v1.push_back( 1 );
   cout << v1.back( ) << endl;
   v1.push_back( 2 );
   cout << v1.back( ) << endl;
   v1.pop_back( );
   cout << v1.back( ) << endl;
}

Output

1
2
1

See Also

vector Class | vector Members | vector::push_back and vector::pop_back Sample

Show:
© 2014 Microsoft. All rights reserved.