title: Initialization of an array of class objects c++
body: <p>I'm attempting to initialize an array of class objects across a .h and .cpp file. I initially declared it(game_map[12]) in the .h file as shown below:</p>
  
  <pre><code>    #include &lt;string&gt;
  
      using namespace std;
  
      class Game {
  
      public:
          Game();
          ~Game();
          void test();
          void InitializeMap(Game &amp;game);
  
      private:
          class Room {
          public:
              Room (string desc);
              Room();
              ~Room();
              void PrintDesc(Room &amp;current);
              void SetDirection(int array_index, Room &amp;current);
  
              string description;
              static int adjacent[3];rooms.
              static string direction[4];
          };
  
  static Room game_map[12]; //Here is my array declaration
  };
  .
  .
  .
  .
  </code></pre>
  
  <p>However, when I try to initialize game_map in the implementation file...</p>
  
  <pre><code>#include "Game.h"
  
  using namespace std;
  
  /*Public members*/
  Game::Game(){}
  Game::~Game(){}
  /*Private members*/
  
  Room Game::game_map[12] = {Room("scary")}; //trying to initialize here
  .
  .
  .
  /*Room*/
  
  int Game::Room::adjacent[] = {-1,-1,-1};
  string Game::Room::direction[] = {"-1","-1","-1","-1"};
  
  Game::Room::Room() {}
  
  Game::Room::Room(string descript) {
      description = descript;
  }
  
  
  Game::Room::~Room() {}
  
   .
   .
   .
  </code></pre>
  
  <p>I get an error saying that Room is undefined, despite that fact that the Room constructor on the right hand side seems to be recognized. I've tried putting the declaration after the Room constructor, but that didn't fix the problem. Can someone tell me what is going on here?</p>
  
  <p>Thanks!</p>