title: C++ "was not declared in this scope" compile error
body: <p>New to C++. In the following program I'm writing I get this error:</p>
  
  <pre><code>g++ -o Blob blob.cc
  blob.cc: In function 'int nonrecursivecountcells(color (*)[7], int, int)':
  blob.cc:41: error: 'grid' was not declared in this scope
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  enum color {BACKGROUND, ABNORMAL, TEMPORARY};
  const int ROW_SIZE = 7;
  const int COL_SIZE = 7;
  int nonrecursivecountcells(color[ROW_SIZE][COL_SIZE], int, int);
  using namespace std;
  
  
  int main() 
  {
    color grid[ROW_SIZE][COL_SIZE] =
      {{BACKGROUND, ABNORMAL, BACKGROUND, ABNORMAL, BACKGROUND, BACKGROUND, BACKGROUND},
        {ABNORMAL, ABNORMAL, BACKGROUND, ABNORMAL, BACKGROUND, BACKGROUND, BACKGROUND},
         {BACKGROUND, BACKGROUND, ABNORMAL, ABNORMAL, BACKGROUND, BACKGROUND, ABNORMAL},
          {BACKGROUND, BACKGROUND, BACKGROUND, ABNORMAL, ABNORMAL, ABNORMAL, BACKGROUND},
           {BACKGROUND, BACKGROUND, BACKGROUND, ABNORMAL, BACKGROUND, BACKGROUND, BACKGROUND},
            {BACKGROUND, BACKGROUND, BACKGROUND, BACKGROUND, BACKGROUND, ABNORMAL, BACKGROUND},
             {BACKGROUND, ABNORMAL, ABNORMAL, BACKGROUND, BACKGROUND, BACKGROUND, ABNORMAL}};
  
     cout &lt;&lt; "Enter row number" &lt;&lt; endl;
     int row;
     cin &gt;&gt; row;
     cout &lt;&lt; "Enter column number" &lt;&lt; endl;
     int column;
     cin &gt;&gt; column;
  
     int number = nonrecursivecountcells(grid, row, column);
     cout &lt;&lt; "Number off cells in the blob that contains grid[" &lt;&lt; row &lt;&lt; "][" &lt;&lt; column &lt;&lt; "] are: " &lt;&lt; number &lt;&lt; endl;
  
     return 0;
  
  }
  
  int nonrecursivecountcells(color[ROW_SIZE][COL_SIZE], int row, int column)
  {
    if (row &lt; 0 || row &gt;= ROW_SIZE || column &lt; 0 || column &gt;= COL_SIZE)
    {
      return 0;
    }
  
    else if (grid[row][column] != ABNORMAL)
    {
      return 0;
    }
  
    else
    {
      grid[row][column] = TEMPORARY;
      return 1
      + nonrecursivecountcells(grid, row - 1, column - 1) + nonrecursivecountcells(grid, row - 1, column)
      + nonrecursivecountcells(grid, row - 1, column + 1) + nonrecursivecountcells(grid, row, column + 1)
      + nonrecursivecountcells(grid, row + 1, column + 1) + nonrecursivecountcells(grid, row + 1, column)
      + nonrecursivecountcells(grid, row + 1, column - 1) + nonrecursivecountcells(grid, row, column - 1);
    }
  }
  </code></pre>
  
  <p>Can anyone help me out here? Thanks.</p>