Namespaces
Variants
Views
Actions

Talk:cpp/container/vector

From cppreference.com
< Talk:cpp‎ | container
Revision as of 11:26, 15 February 2015 by Wilhelmtell (Talk | contribs)

--BohdanKornienko (talk) 13:23, 16 October 2013 (PDT)

Small example to use vector header:

#include <iostream>
#include <vector>

int main(int argc, char **argv)
{
    std::vector<int> vec;

    vec.insert(vec.begin(), 1);
    vec.insert(vec.end(), 2);
    vec.insert(vec.end(), 3);

    vec.erase(vec.begin() + 1);

    std::cout << "count: " << vec.size()
        << "\ncapacity: " << vec.capacity() << std::endl;

    return 0;
}