title: Function defined in scope but the compiler complains that it is out of scope
body: <p>I tried to implement strassens algorithm for two 2x2 matrices in order to make a recursive matrix multiplication algorithm however the implementation doesn't compile giving me errors like:</p>
  
  <blockquote>
    <p>"strassen was not declared in this scope"
    and
    "unqualified-id"</p>
  </blockquote>
  
  <p>Here's the code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  
  using namespace std;
  
  int[][] strassen(int A[][2], int B[][2])
  {
      int s1 = B[0][1] - B[1][1];
      int s2 = A[0][0] + A[0][1];
      int s3 = A[1][0] + A[1][1];
      int s4 = B[1][0] - B[0][0];
      int s5 = A[0][0] + A[1][1];
      int s6 = B[0][0] + B[1][1];
      int s7 = A[0][1] - A[1][1];
      int s8 = B[1][0] + B[1][1];
      int s9 = A[0][0] - A[1][0];
      int s10 = B[0][0] + B[0][1];
  
      int p1 = A[0][0] * s1;
      int p2 = s2 * B[1][1];
      int p3 = s3 * B[0][0];
      int p4 = A[1][1] * s4;
      int p5 = s5 * s6;
      int p6 = s7 * s8;
      int p7 = s9 * s10;
  
  int C[2][2];
  
  C[0][0] = p5 + p4 - p2 + p6;
  C[0][1] = p1 + p2;
  C[1][0] = p3 + p4;
  C[1][1] = p5 + p1 - p3 - p7;
  
  return C[][];
  }
  
  int main()
  {
      int A[2][2] = {{1,3},{7,5}};
      int B[2][2] = {{6,8},{4,2}};
      int C[][2] = strassen(A,B);
      cout&lt;&lt;C[0][0]&lt;&lt;endl&lt;&lt;C[0][1]&lt;&lt;endl&lt;&lt;C[1][0]&lt;&lt;endl&lt;&lt;C[1][1]&lt;&lt;endl;
      return 0;
  }
  </code></pre>
  
  <p>Could you tell me why I'm getting the compile time errors.
  I also need to know how to <code>malloc</code> space for a 2D array, as my current implementation of <code>C</code> will go out of scope as soon as the function exits returning garbage values.</p>