title: What's the Difference Between func(int &param) and func(int *param)?
body: <p>In the following code, both <code>amp_swap()</code> and <code>star_swap()</code> seems to be doing the same thing. So why will someone prefer to use one over the other? Which one is the preferred notation and why? Or is it just a matter of taste?</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  void amp_swap(int &amp;x, int &amp;y)
  {
      int temp = x;
      x = y;
      y = temp;
  }
  
  void star_swap(int *x, int *y)
  {
      int temp = *x;
      *x = *y;
      *y = temp;
  }
  
  int main()
  {
      int a = 10, b = 20;
      cout &lt;&lt; "Using amp_swap(): " &lt;&lt; endl;
      amp_swap(a, b);
      cout &lt;&lt; "a = " &lt;&lt; a &lt;&lt; ", b = " &lt;&lt; b &lt;&lt; endl;
      cout &lt;&lt; "Using star_swap(): " &lt;&lt; endl;
      star_swap(&amp;a, &amp;b);
      cout &lt;&lt; "a = " &lt;&lt; a &lt;&lt; ", b = " &lt;&lt; b &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>Thanks for your time!</p>
  
  <hr>
  
  <p>See Also</p>
  
  <p><H2><a href="https://stackoverflow.com/questions/57483"><strong>Difference between pointer variable and reference variable in C++</strong></a></H2></p>