Tic-Tac-Toe problem

I am following a tutorial for C++ where it is split into chapters, and at the end of the chapters, there is a game you must make. Here is the link: http://ebooks.z0ro.com/ebooks/C_and_C%2B%2B/C%2B%2B_Through_Game_Programming.pdfI am on chapter 6 for references where u must make a tic-tac-toe game

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;
const char X = 'X';
const char O = 'O';
char EMPTY;
const char TIE = 'T';
const char NO_ONE = 'N';

void instructions();
char askYesNo(string question);
int askNumber(string question, int high, int low = 0);
char humanpiece();
char opponent(char piece);
void displayBoard(const vector<char>& board);
char winner(const vector<char>& board);
bool isLegal(const vector<char>& board, int move);
int humanMove(const vector<char>& board, char human);
int computerMove(vector<char> board, char computer);
void announceWinner(char winner, char computer, char human);
int main()
{
int move;
const int num_squares = 9;
vector<char> board(num_squares, EMPTY);
instructions();
char human = humanpiece();
char computer = opponent(human);
char turn = X;
displayBoard(board);

while(winner(board) == NO_ONE)
{
    if(turn == human)
    {
        move = humanMove(board, human);
        board[move] = human;
    }

    else
    {
        move = computerMove(board, computer);
        board[move] = computer;
    }
    displayBoard(board);
    turn = opponent(turn);
}
    announceWinner(winner(board, computer, human));
    return 0;
}

The problem is that when i compile this, i get 2 errors: one says the announcewinner() function has too many arguments, and the other saying it has too little. How is this possible? Note: I didnt include function code as it would take too long for the function codes. If you need the function list and their code, please say so. Thank you for help.
Last edited on
Your declaration: void announceWinner(char winner, char computer, char human)
So, announceWinner has 3 parameters.

You only call it in one place, on line 51, so I'm a little confused by your assertion that you're getting multiple errors. (Actually giving us the errors verbatim would've been helpful.)

If you'll notice on line 51 you supply only one argument which is the return value of the call to winner. According to your declaration, you must supply two more arguments to the function.
announceWinner(winner(board, computer, human));

Did you just mean,
announceWinner(winner(board), computer, human); ?

Maybe your void announceWinner(char winner, char computer, char human);'s body have less than 3 args and make you another error...?
isk, it was the suppose to beannounceWinner(winner(board), computer, human); thank you
Last edited on
Topic archived. No new replies allowed.