Similar Questions:
- STL vector reserve() and copy()
- std::vector reserve() and push_back() is faster than resize() and array index, why?
- std::vector::resize() vs. std::vector::reserve()
#include <vector>
#include <iostream>
using namespace std;
int main() {
vector<vector<int> > vvi;
vvi.resize(1);
vvi[0].reserve(1);
vvi[0][0] = 1;
vector<int> vi = vvi[0];
cout << vi[0]; // cout << vvi[0][0]; works
return 0;
}
This gives me a seg fault, and I can't tell why.