Pointer of a 2D array in C++?
<p>I am writing a function to rotate a NxN matrix by 90 degree.</p>

<p>Here is my function</p>

<pre><code>// "matrix" is an n by n matrix  
void rotateMatrix(int ** matrix, int n)
{
    for(int layer=0; layer &lt; n; layer++)
    {
        int first = layer, last = n - layer -1;
        for(int i=0; i&lt;n; i++)
        {
            int temp = matrix[i][last];
            matrix[i][last] = matrix[first][i];
            matrix[first][i] = matrix[i][first];
            matrix[i][first] = matrix[last][i];
            matrix[last][i]=temp;
        }
    }
}
</code></pre>

<p>Here is how I initialize and call the function in main function:</p>

<pre><code>int m[5][5] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25};
rotateMatrix(m,5);
</code></pre>

<p>What I got from my IDE is:</p>

<pre><code>&gt; error: cannot convert ‘int (*)[5]’ to
&gt; ‘int**’ for argument ‘1’ to ‘void
&gt; rotateMatrix(int**, int)’
</code></pre>

<p>I kinda know why it's wrong since "m" is a int* . However, I am not sure I can I solve this problem?</p>
