pop_back from a vector : vector push pop heap « vector « C++ Tutorial






#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    vector<string> v;
    v.push_back("A");
    v.push_back("B");
    v.push_back("C");

    cout << v.size() << endl;

    for (int i = 0; i < v.size(); ++i)
        cout << v[i] << endl;

    v[0] = "battle axe";
    for (int i = 0; i < v.size(); ++i)
        cout << v[i] << endl;

    cout << v[0] << endl;
    cout << v[0].size() << endl;

    v.pop_back();
    for (int i = 0; i < v.size(); ++i)
        cout << v[i] << endl;

    v.clear();
    if (v.empty())
         cout << "\nYou have nothing.\n";
    else
         cout << "\nYou have at least one item.\n";

    return 0;
}








16.20.vector push pop heap
16.20.1.Perform the heapsort with push_heap and pop_heap
16.20.2.Using pop_back to Erase the Last Element
16.20.3.pop_back from a vector
16.20.4.Demonstrating the STL vector push_back functions