title: How *val and &val differ when passed by reference in C++
body: <pre><code>void funct( int *val1, int &amp;val2)
  {
      *val1= 20;
      val2= 22;
  }
  
  int main()
  {
      int v1=10, v2=12;
      funct(&amp;v1, v2);
      cout&lt;&lt;"v1: "&lt;&lt;v1&lt;&lt;endl&lt;&lt;"v2: "&lt;&lt;v2&lt;&lt;endl;
      return 1;
  }
  </code></pre>
  
  <p>These both, v1 and v2 are called by reference by funct(). But I don't understand, what is difference between both ways apart from syntactical difference. Few questions I want to ask are, </p>
  
  <ul>
  <li>Are both totally same thing?</li>
  <li>Are both equally good in terms of coding practice? </li>
  <li>Situations where one will work, other don't?  </li>
  <li>What are other things that I can do using one, that I can't do using other?</li>
  </ul>
  
  <p>To simplify, I would call:</p>
  
  <pre><code>int *val1 ------- Method 1
  int &amp;val2 ------- Method 2
  </code></pre>