c++ - How can I resize a 2D vector of objects given the width and height? -


my class, gameboard, has member variable 2d vector of object of class tile. gameboard constructor takes width , height parameters.

how can 2d vector of tile objects resize according width , height passed constructor? how can fill tile objects can this?

myvector[i][j].getdisplaychar(); 

snippet

m_vvtiles.resize(iheight);  for(auto = m_vvtiles.begin(); != m_vvtiles.end(); it++ ){      (*it).resize(iwidth,tile(' ')); } 

you have resize outer , inner vectors separately.

myvector.resize(n); (int = 0; < n; ++i)     myvector[i].resize(m); 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -