title: C++ overload operator [ ][ ]
body: <p>I have class CMatrix, where is "double pointer" to array of values.</p>
  
  <pre><code>class CMatrix {
  public:
      int rows, cols;
      int **arr;
  };
  </code></pre>
  
  <p>I simply need to access the values of matrix by typing:</p>
  
  <pre><code>CMatrix x;
  x[0][0] = 23;
  </code></pre>
  
  <p>I know how to do that using:</p>
  
  <pre><code>x(0,0) = 23;
  </code></pre>
  
  <p>But I really need to do that the other way. Can anyone help me with that? Please? </p>
  
  <p>Thank you guys for help at the end I did it this way...</p>
  
  <pre><code>class CMatrix {
  public:
     int rows, cols;
     int **arr;
  
  public:
     int const* operator[]( int const y ) const
     {
        return &amp;arr[0][y];
     }
  
     int* operator[]( int const y )
     {
        return &amp;arr[0][y];
     }
  
     ....
  </code></pre>
  
  <p>Thank you for your help I really appreciate it!</p>