Created
May 23, 2014 18:45
-
-
Save maxfunke/59b2b0cdcee979851a0b to your computer and use it in GitHub Desktop.
Vector usage in c++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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