#include <cstdio> #include <vector> using namespace std; int main(){ vector<int> myVector; // setter: push new myVector.push_back(2); // index = 0 myVector.push_back(5); // index = 1 myVector.push_back(1); // index = 2 // getter: by index printf("%d\n", myVector[1]); // 5 // get size int size = myVector.size(); printf("size = %d\n", size); return 0; }
No comments:
Post a Comment