Getting right value from an array within a class that behaves like matrix
<p>I've got class, that behaves lika a matrix, and all operations there like <code>+</code> , <code>-</code>, <code>*</code> etc work well.. But when I'm trying to get a single value, then I get weird values like 2.08252e-317 ...
I've realized, that this bug happens only, when I want to create new metrix this way:</p>

<p><code>const Matrix b = a ;</code></p>

<p>without <code>const</code> it works well...</p>

<p>this is the declaration of my class:</p>

<pre><code>class Matrix {
public:

Matrix(int x, int y);
~Matrix(void);
Matrix operator+(const Matrix &amp;matrix) const;
Matrix operator-() const; 
Matrix operator-(const Matrix &amp;matrix) const; 
Matrix operator*(const double x) const; 
Matrix operator*(const Matrix &amp;matrix) const;

class Proxy {
    Matrix* _a;
    const Matrix* _constA;
    int _i;
public:

  Proxy(Matrix&amp; a, int i) : _a(&amp;a), _i(i) {
    }

    Proxy(const Matrix&amp; constA, int i) : _constA(&amp;constA), _i(i) {
    }

    double&amp; operator[](int j) {
        return _a-&gt;_arrayofarrays[_i][j];
    }
};

Proxy operator[](int i) {
    return Proxy(*this, i);
}

Proxy operator[](int i) const {
    return Proxy(*this, i);
}



// copy constructor

Matrix(const Matrix&amp; other) : _arrayofarrays() {
    _arrayofarrays = new double*[other.x ];
    for (int i = 0; i != other.x; i++)
        _arrayofarrays[i] = new double[other.y];

    for (int i = 0; i != other.x; i++)

        for (int j = 0; j != other.y; j++)
            _arrayofarrays[i][j] = other._arrayofarrays[i][j];

    x = other.x;
    y = other.y;
}
int x, y;
double** _arrayofarrays;
};

 //constructor

 Matrix::Matrix(int x, int y) {
_arrayofarrays = new double*[x];
for (int i = 0; i &lt; x; ++i)
    _arrayofarrays[i] = new double[y];
this-&gt;x = x;
this-&gt;y = y;
}  
</code></pre>

<p>So I create some instance, fill it with values and then, when I want to print value on some index i get those weird values :-/</p>

<p>ie:</p>

<pre><code>Matrix a(3,5);
//fill in the values to a
cout &lt;&lt; a[1][1] &lt;&lt; endl // prints out some nonsence
</code></pre>

<p>Does anybody have any idea, how to rewrite this class to be able to get proper values?</p>
