Program stuck after compilation when trying to acsses private multy-dimensional array : <p>After the code get compile my , while the program trying to access the private array it got stucked. i build a constructor and in this function i can print the array but after that if im trying to access the array from another function its not working.</p>

<p>In this code it stuck while working on mat(1,2) - trying to return arr[1][2]:</p>

<p>i tried to allocate the array in a different way, to make [] operator but nothing seems to work.</p>

<p>main file :</p>

<pre><code>    #include "matrix.h"
    #include &lt;iostream&gt;

    int main() {

        Matrix&lt;4, 4&gt; mat;
            mat(1,2);
        std::cout &lt;&lt; mat &lt;&lt; std::endl;
    return 0;
    }
</code></pre>

<p>.h file :</p>

<pre><code>    #ifndef matrix_h
    #define matrix_h

    #include &lt;iostream&gt;

    template &lt;int row, int col ,typename T=int&gt;
    class Matrix {
    public:
Matrix(int v = 0) { // constructor with deafault value of '0'
    int **arr = new int*[row]; //initializing place for rows
    for (int j = 0;j &lt; row;j++) {
        arr[j] = new int[col];
    }
    for (int i = 0;i &lt; row;i++) 
        for (int j = 0;j &lt; col;j++) 
            arr[i][j] = v;
}

T&amp; operator () (int r, int c) const { 
    return arr[r][c];
}

friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; out,const Matrix &lt;row,col,T&gt; mat) { 
    for (int i = 0;i &lt; row;i++) {
        for (int j = 0;j &lt; col;j++) {
            out &lt;&lt; mat(i,j) &lt;&lt; " ";
        }
        out &lt;&lt; std::endl;
    }
    return out;
}

    private:
        T** arr;
    };

    #endif //matrix_h
</code></pre>
