title: C++ Compiler Error 2086 redefinition
body: <p>I have a <code>.cpp</code> file that must include <code>Console.h</code>. In the file I'm trying to create a map (used later on for a game).</p>
  
  <p>Error C2086: 'int nMapArray[15][20]: redefinition</p>
  
  <pre><code>#include "Console.h"
  #include &lt;Windows.h&gt;
  #include &lt;stdint.h&gt;
  
  // Map dimensions
  #define MAP_WIDTH   20
  #define MAP_HEIGHT  15
  
  
  // Tile Types
  #define TILE_FLOOR      0
  #define TILE_WALL       1
  
  
  // Map declaration
  int nMapArray[ MAP_HEIGHT ][ MAP_WIDTH ];
  
  // Map Layout
  int nMapArray[ MAP_HEIGHT ][ MAP_WIDTH ]= 
  {
              { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
              { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
              { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 },
              { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
              { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
              { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
              { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
              { 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0 },
              { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
              { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
              { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
              { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
              { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
              { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
              { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
  };
  </code></pre>
  
  <p>I know that I'm only supposed to declare <code>nMapArray</code> once but I'm not sure which one to discard. If I discard <code>int nMapArray[ MAP_HEIGHT ][ MAP_WIDTH ];</code> then it will generate two errors:
  LNK2019: unresolved external symbol
  and
  LNK1120: unresolved externals</p>
  
  <p>Did a bit of googling but I still can't find the fix so help would be appreciated.</p>
  
  <p>EDIT:
  Ok so following the advice of many to get rid of the first inisialisation. From here I get two errors:</p>
  
  <p>error LNK2019: unresolved external symbol "public: virtual class IConsole &amp; __thiscall Win32Console::Color(unsigned short)" (?Color@Win32Console@@UAEAAVIConsole@@G@Z) referenced in function "void __cdecl DrawTile(int,int)" (?DrawTile@@YAXHH@Z)</p>
  
  <p>and</p>
  
  <p>error LNK1120: 1 unresolved externals</p>
  
  <p>Full code:</p>
  
  <pre><code>#include "Console.h"
  #include &lt;Windows.h&gt;
  #include &lt;stdint.h&gt;
  
  // Map dimensions
  #define MAP_WIDTH   20
  #define MAP_HEIGHT  15
  
  
  // Tile Types
  #define TILE_FLOOR      0
  #define TILE_WALL       1
  
  // Map Layout
  int nMapArray[ MAP_HEIGHT ][ MAP_WIDTH ]= 
  {
              { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
              { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
              { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 },
              { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
              { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
              { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
              { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
              { 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0 },
              { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
              { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
              { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
              { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
              { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
              { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
              { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
  };
  
  void DrawMap( void );
  bool IsPassable( int x, int y );
  void DrawTile( int x, int y );
  
  int main( void )
  {
      console.SetTitle( "Article Two Demo" );
  
      // Declare the player's position
      int nPlayerX = 4;
      int nPlayerY = 4;
  
      // Main game loop
      while( true )
      {
          // Draw the map
          DrawMap();
  
          // Draw the player to the screen
          console.Color( RED );
          console.Position( nPlayerX, nPlayerY );
          console &lt;&lt; '@';
  
          // Input phase - Wait for the player to do something
          KEYPRESS sKeyPress = console.WaitForKeypress();
  
          // Process the input
          switch( sKeyPress.eCode )
          {
              // Move up
              case CONSOLE_KEY_UP:
                  // Can we move to the tile above?
                  if( IsPassable(nPlayerX, nPlayerY-1) )
                  {
                      // Move up
                      nPlayerY--;
                  }
                  break;
  
              // Move left
              case CONSOLE_KEY_LEFT:
                  // Can we move to the tile to the left of the player?
                  if( IsPassable(nPlayerX-1, nPlayerY) )
                  {
                      // Move left
                      nPlayerX--;
                  }
                  break;
  
              // Move right
              case CONSOLE_KEY_RIGHT:
                  // Can we move to the tile to the right of the player
                  if( IsPassable(nPlayerX+1, nPlayerY ) )
                  {
                      // Move right
                      nPlayerX++;
                  }
                  break;
  
              // Move down
              case CONSOLE_KEY_DOWN:
                  // Can we move to the tile below the player?
                  if( IsPassable(nPlayerX, nPlayerY+1) )
                  {
                      // Move down
                      nPlayerY++;
                  }
                  break;
  
              // Escape key
              case CONSOLE_KEY_ESCAPE:
                  // Quit the program
                  return 0;
  
              // Ignore any other keys
              default:
                  break;
          }
      }
  
      // If execution gets here, the program is done
      return 0;
  }
  
  // IsPassable Function ///////////////////////////////////////////////////////////////////
  //
  //  This function analyzes the coordinates of the map array specified and returns
  //  true if the coordinate is passable (able for the player to occupy), false if not.
  //
  bool IsPassable( int x, int y )
  {
      // Before we do anything, make darn sure that the coordinates are valid
      if( x &lt; 0 || x &gt;= MAP_WIDTH || y &lt; 0 || y &gt;= MAP_HEIGHT )
          return false;
  
      // Store the value of the tile specified
      int nTileValue = nMapArray[y][x];
  
      // Return true if it's passable
      if( nTileValue == TILE_FLOOR)
          return true;
  
      return false;
  }
  
  // DrawMap Function //////////////////////////////////////////////////////////////////////
  //
  //  This function draws the entire map to the screen.
  //
  void DrawMap( void )
  {
      for( int y = 0; y &lt; MAP_HEIGHT; y++ )
      {
          for( int x = 0; x &lt; MAP_WIDTH; x++ )
          {
              DrawTile(x, y);
          }
      }   
  }
  
  // DrawTile Function /////////////////////////////////////////////////////////////////////
  //
  //  Draws a map tile for the map coordinates specified.
  //
  void DrawTile( int x, int y )
  {
      console.Position( x, y );
      switch( nMapArray[y][x] )
      {
          case TILE_FLOOR:
              console.Color( GREY );
              console &lt;&lt; '.';
              break;
  
          case TILE_WALL:
              console.Color( GREY );
              console &lt;&lt; '#';
              break;
  
      }
  }
  
  //////////////////////////////////////////////////////////////////////////////////////////
  </code></pre>
  
  <p>In <code>Console.h</code> I haven't put the layout in (because I'm not entirely sure how to do that).</p>