sharing an object with multiple classes
<p>I have 3 classes namely Board, Game, and AI</p>

<p>i want to have the object chessBoard of Board class to be use by Game and AI, and also by the Board Class. I want them to access that single chessBoard object (sharing)</p>

<p>problem is, it gives me the infamous fatal error LNK1169: one or more multiply defined symbols found. Also, there are Board.h,Game.h and AI.h (only declarations in them), and i also have their corresponding .cpp files. Each .h files have guards included (#ifndef _XXXXXX_H_)</p>

<p>I tried to include Board chessBoard inside Board.h file (just below the class), and it seems guards are not working.</p>

<pre><code>Error   7   error LNK2005: "class Board chessBoard" (?chessBoard@@3VBoard@@A)     already defined in AI.obj C:\Users\xxxx\Documents\Visual Studio 2010\Projects\CHESSv3\CHESSv3\Board.obj   CHESSv3
Error   8   error LNK2005: "class Board chessBoard" (?chessBoard@@3VBoard@@A)     already defined in AI.obj C:\Users\xxxxx\Documents\Visual Studio 2010\Projects\CHESSv3\CHESSv3\Game.obj   CHESSv3
Error   9   error LNK2005: "class Board chessBoard" (?chessBoard@@3VBoard@@A) already defined in AI.obj C:\Users\xxxxx\Documents\Visual Studio 2010\Projects\CHESSv3\CHESSv3\ProgramEntryPoint.obj  CHESSv3
</code></pre>

<p>AI.h</p>

<pre><code>#ifndef _AI_H_
#define _AI_H_
#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;

struct node {
    string position;
    string nextPosition;
    float score;
    int level;
    float totalscore;
    node* up;
    node* right;
    node* left;
    bool approved;
    string move;
};

class AI {
private:
    //string board;
    //string board[8][8];
    int score1;
    int maxscore;
    int totalscore;
public: 
    void GetBoard(string[][8]);
    void AnalyzeMyPositions();
    void ExecuteAdvanceHeuristicMove();
};

#endif
</code></pre>

<p>Game.h</p>

<pre><code>#ifndef _GAME_H_
#define _GAME_H_

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
#include &lt;sstream&gt;
#include &lt;queue&gt;
#include &lt;stack&gt;
#include &lt;cmath&gt;

using namespace std;

class Game {
public:
    char WhosTurn();
    bool Playable();
    bool GetMoveFromPlayer();
    void TurnOver();
    Game();
private:
    char turn;
};

#endif
</code></pre>

<p>Board.h</p>

<pre><code>#ifndef _BOARD_H_
#define _BOARD_H_
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
#include &lt;sstream&gt;
#include &lt;queue&gt;
#include &lt;stack&gt;
#include &lt;cmath&gt;
using namespace std;

class Board {
public:
    bool SquareChecker(string);
    bool MoveChecker(string);
    Board();
    void PrintBoard();
    int Execute(string);
    void UnExecute();
    string CB[8][8];
private:
    char turn;
    vector&lt;string&gt; BoardRecord;
    stack&lt;string&gt; CBR;
    //string CB[8][8];
};

Board chessBoard;

#endif
</code></pre>
