title: Own matrix class multiply operator
body: <p>I wrote an IntegerMatrix class to add my own methods to work with matrices.   Now I've written a function like this:</p>
  
  <pre><code>IntegerMatrix** IntegerMatrix::multiplyMatrix(IntegerMatrix** table2)
  </code></pre>
  
  <p>(It's a double pointer because I'm holding a huge array of pointers to 4x4 2D arrays.) so I simply could do this:</p>
  
  <pre><code>matrix1.multplyMatrix(matrix2)
  </code></pre>
  
  <p>One little problem is the <code>*</code> isn't defined for my own class. So I thought to overload this operator that I could do something like this:</p>
  
  <pre><code>sum += this-&gt;table[i][k] * table2[k][j];
  </code></pre>
  
  <p>But how can I get the right <code>i</code> and <code>k</code> in the overloaded operator, which is defined like this:</p>
  
  <pre><code>IntegerMatrix IntegerMatrix::operator*(const IntegerMatrix &amp; k);
  </code></pre>
  
  <p>The only problem I can't figure out right now is how to get the right values ?</p>
  
  <p>EDIT:</p>
  
  <p>I've rewrote this and now I have: </p>
  
  <pre><code>IntegerMatrix IntegerMatrix::operator*(const IntegerMatrix &amp; table2)
  {
      int i, j, k;
      int sum;
      IntegerMatrix * result = new IntegerMatrix(SIZE);
  
      for (i = 0; i &lt; SIZE; i++) {
          for (j = 0; j &lt; SIZE; j++) {
              sum = 0;
              for (k = 0; k &lt; SIZE; k++) {
                  sum += this-&gt;table[i][k] * table2[k][j];
              }
              result[i][j] = sum;
          }
      }
      return *result;
  
  }
  </code></pre>
  
  <p>That gives me just an error on the [] :</p>
  
  <pre><code>Binary '[' : 'IntegerMatrix' does not define this operator or a conversiont o a type acceptable to the predefined operator.
  </code></pre>