I'm a newbie when it comes to C++ and coding in general as this is only my second course. For my assignment, I have to code a program for a memory game where the user selects cards in a 2D array to try to match them. Right now, however, I'm struggling to get my function call for initializeBoard() to compile without an error. The message I get is:
main.cpp:63:3: error: no matching function for call to
'initializeBoard'
initializeBoard(gameBoard, rows);
main.cpp:35:6: note: candidate function not viable: no known
conversion from 'int [rows][col]' to 'int (*)[col]' for 1st
argument
A simplified copy of my code is written below containing the lines I believe are involved in the error.
int rows = 4;
int col = 4;
void initializeBoard(int gameBoard[][col], int rows);
int main()
{
int players;
string p1Name, p2Name, p3Name, p4Name, p5Name;
rules();
getPlayers(players, p1Name, p2Name, p3Name, p4Name, p5Name);
if (2 < players && players < 5)
{
rows = 6;
col = 6;
}
else if (players == 5)
{
rows = 8;
col = 8;
}
int (gameBoard)[rows][col];
initializeBoard(gameBoard, rows); // I get an error saying there is no matching function for call to 'initializeBoard'
}
Could someone explain to me where I am going wrong and help me find a solution to the issue?