Skip to content

Instantly share code, notes, and snippets.

@maxfunke
Created May 23, 2014 18:45
Show Gist options
  • Save maxfunke/59b2b0cdcee979851a0b to your computer and use it in GitHub Desktop.
Save maxfunke/59b2b0cdcee979851a0b to your computer and use it in GitHub Desktop.
Vector usage in c++
// init vector
vector <int> myVec(10);
//size of vector
int vSize = myVec.size();
// access to element n
myVec[0] = 1; // no buffer checking
myVec.at(1) = 2;
// resize vector
myVec.push_back(11); // extends vector by 1 and give it value of parameter
myVec.resize(myVec.size()+1); // extends vector by 1 and initializes last element with 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment