c++ - Vector of a Vector troubles -


basic problem can please me understand how use vector of vector. take example vector< vector<int> > help. not understand if vector of ints each vector of ints or if vector of vector of ints? don't understand how utilize it.

example code

vector< vector<int> > test[500]; test[0].emplace_back(1); cout << test[0][0]; test[50].emplace_back(4); cout << " " <<test[50][0];  -console- 1 50 //this not happens btw, desired results 

disclaimer have spent better part of morning testing , googling this. please :) did hw. can't find documentation of vectors of vector. have correct libraries , using namespace std. noob , understand namespaces bad practice, convient me right now.

basically want set size of vector filled each pt being vector of int. rather not go way of separate class. vector of vector of int, right thing looking into?

thank :)

this vector of int:

std::vector<int> v; 

this vector of vectors of int:

std::vector<std::vector<int>> v2; 

this array of vectors of vectors of ints, have:

std::vector<std::vector<int>> test[500]; 

each element of array std::vector<std::vector<int>>. test[0] 1 of those.

if want vector of 500 default constructed vectors of int, need

std::vector<std::vector<int>> test(500); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -