CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

Vector push_back and size

C++ code walkthrough · Question 31
easyVectors

Code

Read carefully. What does this print?
1#include <iostream>
2#include <vector>
3using namespace std;
4int main() {
5 vector<int> v;
6 v.push_back(10);
7 v.push_back(20);
8 v.push_back(30);
9 cout << v.size() << " " << v[1] << endl;
10 return 0;
11}

Your answer