My class, GameBoard
, has a member variable that is a 2D vector of an object of the class Tile
. The GameBoard
constructor takes width and height as parameters.
How can I get the 2D vector of Tile
objects to resize according to the width and height passed to the constructor? How can I fill it with Tile
objects so that I can do something like this?
myVector[i][j].getDisplayChar();
Snippet
m_vvTiles.resize(iHeight);
for(auto it = m_vvTiles.begin(); it != m_vvTiles.end(); it++ ){
(*it).resize(iWidth,Tile(' '));
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…