Hello all. I am wrapping up a tictactoe program and have run across a problem. I divided my program into three files.. the main .cpp file, a tictactoe class .h file, and a tictactoe class .cpp file.
I am not sure how to set up my preprocessor directives which I believe is causing errors. Here are my directives per file:
Source1.cpp file -
1 2 3 4
|
#include <iostream>
#include "gameBoard.h"
using namespace std;
|
gameBoard.h file -
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
|
#include <string>
#include <vector>
using namespace std;
class gameBoard
{
public:
void printBoard() const;
void setPlayers();
void getMove(int player);
bool isMoveValid() const;
void setMove(int player);
bool isWinner() const;
string getPlayerOne() const;
string getPlayerTwo() const;
gameBoard();
private:
char board[9];
char move;
vector<char> movesTaken;
string playerOne;
string playerTwo;
};
|
gameBoardImp.cpp (implementation) -
1 2 3 4 5 6
|
#include <iostream>
#include <string>
#include <vector>
#include "gameBoard.h"
using namespace std;
|
Here are the errors:
1>------ Build started: Project: TicTacToe, Configuration: Debug Win32 ------
1> Source1.cpp
1>Source1.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall gameBoard::getPlayerTwo(void)const " (?getPlayerTwo@gameBoard@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function _main
1>Source1.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall gameBoard::getPlayerOne(void)const " (?getPlayerOne@gameBoard@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function _main
1>Source1.obj : error LNK2019: unresolved external symbol "public: bool __thiscall gameBoard::isWinner(void)const " (?isWinner@gameBoard@@QBE_NXZ) referenced in function _main
1>Source1.obj : error LNK2019: unresolved external symbol "public: void __thiscall gameBoard::setMove(int)" (?setMove@gameBoard@@QAEXH@Z) referenced in function _main
1>Source1.obj : error LNK2019: unresolved external symbol "public: bool __thiscall gameBoard::isMoveValid(void)const " (?isMoveValid@gameBoard@@QBE_NXZ) referenced in function _main
1>Source1.obj : error LNK2019: unresolved external symbol "public: void __thiscall gameBoard::getMove(int)" (?getMove@gameBoard@@QAEXH@Z) referenced in function _main
1>Source1.obj : error LNK2019: unresolved external symbol "public: void __thiscall gameBoard::printBoard(void)const " (?printBoard@gameBoard@@QBEXXZ) referenced in function _main
1>Source1.obj : error LNK2019: unresolved external symbol "public: void __thiscall gameBoard::setPlayers(void)" (?setPlayers@gameBoard@@QAEXXZ) referenced in function _main
1>Source1.obj : error LNK2019: unresolved external symbol "public: __thiscall gameBoard::gameBoard(void)" (??0gameBoard@@QAE@XZ) referenced in function _main
1>C:\Users\Kevin\documents\visual studio 2010\Projects\TicTacToe\Debug\TicTacToe.exe : fatal error LNK1120: 9 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========