title: Why does my code giving me "mismatch in formal parameter list"?
body: <p>I am trying to transfer the elements from a source stack to a destination stack. And for that i am using some variables and making sure that get transfered into the destination stack in the same order as they were in the source stack. I wrote the following code</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stack&gt;
  using namespace std;
  
  template &lt;typename S&gt;
  void transferByVar(stack&lt;S&gt; &amp;source, stack&lt;S&gt; &amp;dest)
  {
      int var = 0;
      S topVal;
      if (source.empty())
          return;
      else if (source.size() == 1)
      {
          dest.push(source.top());
          source.pop();
      }
  
      int size = source.size();
      while (count != size)
      {
          topVal = source.top();
          source.pop();
          while (source.size() != count)
          {
              dest.push(source.top());
              source.pop();
          }
          source.push(topVal);
          while (!dest.empty())
          {
              source.push(dest.top());
              dest.pop();
          }
          ++count;
      }
  }
  
  int main()
  {
      stack &lt;int&gt; s1;
      stack&lt;int&gt; s2;
      s1.push(0);
      s1.push(1);
      s1.push(2);
      s1.push(3);
      s1.push(4);
      s1.push(5);
      s1.push(6);
      s1.push(7);
      s1.push(8);
      s1.push(9);
      transferByVar(s1, s2);
      int size = s2.size();
      for (int i = 0; i &lt; size; i++)
      {
          cout &lt;&lt; s2.top() &lt;&lt; &quot; &quot;;
          s2.pop();
      }
      return 0;
  }
  </code></pre>
  <p>but it gives me an error of C2563: mismatch of formal parameter list. What can I do to fix this?</p>