I want to create array m x n with . My code:
std::vector<std::vector<c_atom*>> new_lattice;
new_lattice.resize(maxX);
for (auto it : new_lattice)
it.resize(maxY);
for(int i = 0; i<maxX; i++)
for (int j = 0; j < maxY; j++)
{
c_atom *at = new c_atom;
cout << new_lattice[i].size() << endl; // here i get 0. why?
new_lattice[i][j] = at;
}
but memory is not allocated for each array of new_lattice and I get size = 0 for each array of new_lattice. When I want to add pointer of atom in my array on position [i][j] i get error "array out of range". How i can solve this problem?