Ambiguous call to overloaded function (learning about templates)
<p>I started learning about templates and I copied the code from my book but the compiler is giving me this error </p>

<blockquote>
  <p>Error 1 error: 'swap' : ambiguous call to overloaded function"</p>
</blockquote>

<p>Here is my program</p>

<pre><code>#include &lt;iostream&gt;

template &lt;typename X&gt;
void swap(X &amp;a, X &amp;b);

int _tmain(){
    using namespace std;
    int a, b;

    cout &lt;&lt; "enter two numbers:\n";
    cin &gt;&gt; a &gt;&gt; b;
    cout &lt;&lt; "Your numbers are: " &lt;&lt; a &lt;&lt; ", " &lt;&lt; b &lt;&lt; endl;

    swap(a, b); //error is here
    cout &lt;&lt; "Your numbers reversed are: " &lt;&lt; a &lt;&lt; ", " &lt;&lt; b &lt;&lt; endl;

    return 0;
}

template &lt;typename X&gt;
void swap(X &amp;a, X &amp;b){
    X temp = a;
    a = b;
    b = temp;
}
</code></pre>
