title: Passing a pointer by reference
body: <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  void merge(int *&amp; toMerge, int lo, int mid, int hi)
  {
      int merged[hi+1];
      int i = lo, j = mid+1;
      for (int k = lo; k &lt;= hi; k++)
      {
          if (i &gt; mid) {merged[k] = toMerge[j]; j++;}
          else if (j &gt; hi) {merged[k] = toMerge[i]; i++;}
          else if (toMerge[j] &lt; toMerge[i]) {merged[k] = toMerge[j]; j++;}
          else {merged[k] = toMerge[i]; i++;}
      }
      toMerge = merged;
  }
  
  int main(int argc, const char * argv[])
  {
  
      int x[8] = {1,7,4,6,2,7,3,2};
      merge(x, 0, 7, 3);
      return 0;
  }
  </code></pre>
  
  <p>I am trying to pass a pointer by reference here such that the end result will be that the array <code>x</code> will be sorted. However, my compiler is throwing an error that there is no matching function call for the <code>merge(x, 0, 7, 3)</code>. </p>
  
  <p>I am not sure as to why this is happening because the merge function requires a pointer, and <code>x</code> is a pointer to the first element in the array -- so it should work. Why doesn't it?</p>