I use a 2D array as the board for the board game I am making. Elements are pointers to objects of type "Tile". Indexes are x and y, which indicate horizontal and vertical position, respectively. In the Board class, it looks like this.
vector<vector<Tile*> > playGround;
The problem is that as the game progresses, tiles are added to playGround, and the vector should be able to expand if this requires a new tile position. I am trying to add rows at the top and add columns to the left. I tried using the insert () function, and where my problem is.
Now my code is as follows:
void Board::addRowTop() { Tile* t; int i = 0; maxY++; for ( ; i < maxX ; i++ ) playGround[i].insert(0, t); }
Ignore the variables maxX and maxY; they are not relevant to this issue. The problem is this: insert (0, t) obviously does not work, since "t" is not the data type expected by the function.
My question is simple: why do I need a second insert () argument to solve this problem? I looked on google, but I could not find the correct answer.
Thank you very much in advance.
source share