Namespaces
Variants
Views
Actions

Talk:cpp/container/vector

From cppreference.com
< Talk:cpp‎ | container
Revision as of 12:23, 16 October 2013 by BohdanKornienko (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

Small example to use vector header:

  1. include <iostream>
  2. 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;

}