title: In templates if we create a function and pass variable address as parameters by reference will it give the required output
body: <p>The code given below is related to a template concept in c++. 
  I am not getting a proper result while passing the variables.
  My expected output is swapped numbers.
  However, the compiler is showing an error.</p>
  
  <pre><code>#include&lt;iostream&gt;
  
  using namespace std;
  
  template &lt;class T&gt;
  void swap(T&amp; a,T&amp; b)
  {
      T temp;
      temp=a;
      a=b;b=temp;
  }
  
  int main()
  {
      int a1,b1;
      cin&gt;&gt;a1&gt;&gt;b1;
      swap(a1,b1);
      cout&lt;&lt;a1&lt;&lt;endl&lt;&lt;b1&lt;&lt;endl;
  }
  </code></pre>