title: Normal pointer vs Auto pointer (std::auto_ptr)
body: <p>Code snippet (normal pointer)</p>
  
  <pre><code>int *pi = new int;
  int i = 90;
  pi = &amp;i;
  int k = *pi + 10;
  cout&lt;&lt;k&lt;&lt;endl; 
  delete pi;
  
  [Output: 100]
  </code></pre>
  
  <p>Code snippet (auto pointer)</p>
  
  <p>Case 1:</p>
  
  <pre><code>std::auto_ptr&lt;int&gt; pi(new int);
  int i = 90;
  pi = &amp;i;
  int k = *pi + 10; //Throws unhandled exception error at this point while debugging.
  cout&lt;&lt;k&lt;&lt;endl;
  //delete pi; (It deletes by itself when goes out of scope. So explicit 'delete' call not required)
  </code></pre>
  
  <p>Case 2:</p>
  
  <pre><code>std::auto_ptr&lt;int&gt; pi(new int);
  int i = 90;
  *pi = 90;
  int k = *pi + 10;
  cout&lt;&lt;k&lt;&lt;endl;
  
  [Output: 100]
  </code></pre>
  
  <p>Can someone please tell why it failed to work for case 1?</p>