error c2448

I am getting the above error code in my program stating -- "function-style initializer appears to be a function definition." The problem is that where the error is pointing to is a function definition. Does anyone have any idea whi I am getting, and how I can correct this error?
I have no idea without looking at the code, can you post it?
the error is pointing to the bool function definition. thank you for your help


#include "stdafx.h"
#include <iostream>
#include <iomanip>

using namespace std;

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;

char table [rows][col] = {{'*', '*', '*'},
{'*', '*', '*'},
{'*', '*', '*'}};
showarray(table, rows);

for (int count = 1; count <= 9; count++)
{
if (count % 2 != 0)
{
cout << "Player X's turn.\n";
cout << "Enter a row and column to place an X.\n";
cout << "Row:";
cin >> row;
cout << "Column:";
cin >> column;
cout << "\n";

//Warn player if space is already taken
if (table [row - 1] [column - 1] == 'X' || table [row - 1] [column - 1] == 'O')
{
spacetaken (row, column);
table [row - 1] [column - 1] = 'X';
}
else
table [row - 1] [column - 1] = 'X';

showarray(table, rows);
TestWinner();

if (isWinner == true)
{
cout << "Player X has won!/n";
cout << "The game will now end";

system ("pause");
system ("end");
}

}
else
{

cout << "Player O's turn.\n";
cout << "Enter a row and column to place an O.\n";
cout << "Row:";
cin >> row;
cout << "Column:";
cin >> column;
cout << "\n";

// Warn player if space is already taken
if (table [row - 1] [column - 1] == 'X' || table [row - 1] [column - 1] == 'O')
{
spacetaken(row, column);
table [row - 1] [column - 1] = 'O';
}
else
table [row - 1] [column - 1] = 'O';

showarray(table, rows);

TestWinner();

if (isWinner == true)
{
cout << "Player O has won!/n";
cout << "The game will now end";

system ("pause");
system ("end");
}
}
}
return 0;
}

void showarray (char array[] [col], int rows)
{
cout << "\tColumns\n";
cout << "\t 1 2 3\n";

for (int x = 0; x < rows; x++)
{
cout << "Row " << (x+1) << ": ";

for (int y = 0; y < col; y++)
{
cout << setw(3) << array [x] [y];
}
cout << "\n";
}

}

int spacetaken (int row, int column)
{
cout << "Space already taken, please select another space.\n";
cout << "Row:";
cin >> row;
cout << "Column:";
cin >> column;
cout << "\n";
return row, column;
}

bool TestWinner (table, letter)
{

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;
}
When you initialize the bool TestWinner function, it has 0 parameters.
bool TestWinner();

But when you write the function, you give it (table, letter).
I am still getting the same error, with declaring the parameters
bool TestWinner (char [][col], char);

What am I doing wrong?
The declaration and definition must be exactly the same, with the exception that the declaration doesn't have to have the parameter names.
Last edited on
Topic archived. No new replies allowed.