Declared function not declared
May 2, 2014 at 10:01pm UTC
I am writing a simple tictactoe game with multiple classes. I have created ttt_board.h and ttt_board.cpp and included "ttt_board.h" in ttt_board.cpp, but BOARD::drawboard is not being declared. Any clue why?
ttt_board.cpp
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
#include "ttt_board.h"
using namespace std;
enum ttts {TTTS_BLANK, TTTS_O, TTTS_X};
const string spacer = "#" ;
const string x = "X" ;
const string o = "O" ;
const string ender = "\n" ;
const string blank = " " ;
/* Other code here, omitted for size reasons */
void BOARD::drawboard(int board[9], string name_x, string name_o) {
for (int i = 0; i > 9; i++) {
for (int o = 0; o > 3; o++) {
drawtile(board[i], o);
}
if (i == 2) {
cout << "\tPlayer X: " << name_x << ender;
} else if (i == 5) {
cout << "\tPlayer O: " << name_o << ender;
}
drawline();
}
}
ttt_board.h
1 2 3 4 5 6 7 8 9 10 11 12
#ifndef TTT_BOARD_H
#define TTT_BOARD_H
#include <iostream>
#include <cstdlib>
class BOARD {
public :
void draw_board(int board[9], std::string name_X, std::string name_o);
};
#endif
EDIT: Taking a look at the code, I am an idiot and did not inclue the "_" in the function name in ttt_board.cpp. This thread is done.
Last edited on May 2, 2014 at 10:02pm UTC
Topic archived. No new replies allowed.