Difference between revisions of "Talk:cpp/container/vector"
From cppreference.com
(Created page with "--~~~~ 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)...") |
Wilhelmtell (Talk | contribs) m (format code) |
||
Line 3: | Line 3: | ||
Small example to use vector header: | Small example to use vector header: | ||
− | #include <iostream> | + | {{c|#include <iostream> |
#include <vector> | #include <vector> | ||
Line 21: | Line 21: | ||
return 0; | return 0; | ||
} | } | ||
+ | }} |
Revision as of 11:26, 15 February 2015
--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;
}