c++ vector size
#include <vector> int main() { std::vector<int> myVector = { 666, 1337, 420 }; size_t size = myVector.size(); // 3 myVector.push_back(399); // Add 399 to the end of the vector size = myVector.size(); // 4 }
c++ vector
#include <vector> #include <string> int main() { std::vector<std::string> str_v; str_v.push_back("abc"); str_v.push_back("hello world!!"); str_v.push_back("i'm a coder."); for(auto it = str_v.beigin();it != str_v.end(); it++) { printf("%s\n",it->c_str()); } }
vectors c++
#include <iostream> #include <vector> using namespace std; int main() { // Create a vector containing integers vector<int> v = { 7, 5, 16, 8 }; v.push_back(25); // Adds 25 to the contents of the vector v.push_back(13); // Adds 13 to the contents of the vector // Print out the contents of the vector cout << "v = { "; for (int n : v) { std::cout << n << ", "; } cout << "}; \n"; }
Source: en.cppreference.com
c++ vector
#include <vector> #include <iostream> int main () { std::vector<int> v1; // LINE I v1.push_back(10); // LINE II std::cout<<v1.front()<<":"<<v1.back()<<std::endl; // LINE III return 0; } //code compiles successfully
vector keyword in c++
template < class T, class Alloc = allocator<T> > class vector;
Source: www.tutorialspoint.com