I am working on a Minesweeper for a school project. I am currently working on opening up adjacent squares if the number of mines in adjacent squares is 0. I have written a function to do so.
{
void Square::openAdjacent(int a, int b)
{
for (int i=(a-1); i<=(a+1); i++)
{
for (int j= (b-1); j<=(b+1); j++)
{
if ((i==a && j==b) || (i<=0) || (j<=0) || (i>=board_->size()) || (j>=board_->size())){}
else if (not board_->at(j).at(i).opened_ && count_==0 && (opened_) && (not board_->at(j).at(i).hasMine_)){
board_->at(j).at(i).opened_=true;
if (board_->at(j).at(i).count_==0){
openAdjacent(i, j);
}
}
}
}
}
}
As you can see I have called the function openAdjacent within the same function. I have read around and learnt that this isn't possible in C++. I would like to know if it's possible to work around the problem and how I should do so.