c++ - Initialize and use 2d vector of structs -


i trying initialize 2d vector of structs having

vector <vector <cellvalue>> table;  mstringx = x; mstringy = y;  mlengthx = x.length(); mlengthy = y.length();  vector<cellvalue> myrow (0, mlengthy);  table.push_back(myrow); 

of struct cellvalue

struct cellvalue {     int stringlength;     arrow direction; }; 

and using couple places in code

table[i, j]->stringlength = table[i - 1, j - 1]->stringlength + 1; 

however have feeling using vectors wrong. new vectors , have been told similar arrays.

found out doing wrong. when initializing vector, needed declare table = vector<vector<cellvalue>> (mlengthx, vector<cellvalue>(mlengthy)); , whenever accessing values of table needed table[i][j].stringlength instead of table[i, j]->stringlength