I'm writing a simple game application. A game object is composed of a Board and an AI player. When the AI player is constructed it needs a reference to a board object, so it can interact with it. How can I set up the game class so that its members get constructed properly--considering that one needs a reference to another?
Code:class Game { private: Board theBoard; AI computerPlayer; // AI needs reference to theBoard (above) }; class AI { AI(Board& board_in) : theBoard(board_in) private: Board& theBoard; };




Reply With Quote