I am getting error c2448 'TestWinner' : function-style initializer appears to be a function definition. The error is pointing to the bool function definition, but I am not sure why or how to correct the problem. Does anyone have any ideas as to how to correct this?
const int rows = 3; //Define number of rows in array
const int col = 3; //Define number of columns in array
int row, column;
char table [rows][col];
bool isWinner = false;
char letter;
void showarray(char [][col], int);
int spacetaken (int, int);
bool TestWinner();
int _tmain(int argc, _TCHAR* argv[])
{
int row, column;
if (table(0,0) == letter && table(1,1) == letter && table(2,2) == letter) //diagonal top left to bottom right
{
isWinner = true;
}
if (table(0,2)== letter && table(1,1) == letter && table(0,2) == letter) //diagonal top right to bottom left
{
isWinner = true;
}
if (table(0,0) == letter && table(1,0) == letter && table(2,0) == letter) //straight down, left column
{
isWinner = true;
}
if (table(0,1) == letter && table(1,1) == letter && table(2,1) == letter) //straight down, middle column
{
isWinner = true;
}
if (table(0,2) == letter && table(1,2) == letter && table(2,2) == letter) //straight down, right column
{
isWinner = true;
}
if (table(0,0) == letter && table(0,1) == letter && table(0,2) == letter) //horizontal top row
{
isWinner = true;
}
if (table(1,0) == letter && table(1,1) == letter && table(1,2) == letter) //horizontal middle row
{
isWinner = true;
}
if (table(2,0) == letter && table(2,1) == letter && table(2,2) == letter) //horizontal bottom row
{
isWinner = true;
}
return isWinner;
}
odd. when I change it to bool TestWinner (char table[][3], char letter).. (I just noticed that table and letter are globals. Then this function doesn't need parameters at all) that error goes away.
You have others though. table(0,0) makes no sense. You probably meant table[0][0].