invalid types ‘int[int]’ for array subscript in 2D array : <p>Working on a project that reads integers from a file and puts them into a 2D array. I tested it with a 1D array but when I tried it with a 2D array I kept getting this error "invalid types ‘int[int]’ for array subscript" in my class called "Image" in this function:</p>

<pre><code>void Image::read(int* arr)
{
//Nested loop that reads the file
    for(int i = 0; i &lt; height; i++)
    {
        for(int k = 0; k &lt; width; k++)
        {
            inputFile &gt;&gt; arr[i][k]; //Here's where I get the error
        }
    }
}
</code></pre>

<p>And here is my main function: </p>

<pre><code>int main()
{
    Image test("colorado1.dat"); //File with the integers

    test.setWidth(500);
    test.setHeight(500);

    int array[test.getHeight()][test.getWidth()];

    test.read(array);
    //Loop to test if the function worked
    for(int i = 0; i &lt; 500; i++)
    {
        for(int k = 0; k &lt; 500; k++)
        {
            cout &lt;&lt; array[i][k] &lt;&lt; " ";
        }
    }
}
</code></pre>
