title: What is the output of the following code snippet? What does it mean?
body: <p>I'm studying for a C++/OOP exam and am a little confused with this question on my practice test.</p>
  
  <p>What is the output of the following code snippet?</p>
  
  <pre><code>int *list = new int[5];
  int *ptr;
  for (int i = 0; i &lt; 5; i ++)
  list [ i] = i+ 1;
  ptr = list;
  delete [ ] list;
  cout &lt;&lt; *ptr
  </code></pre>
  
  <ol>
  <li>1</li>
  <li>Address of list</li>
  <li>Address of ptr</li>
  <li>Error – ptr references memory that no longer belongs to the program</li>
  </ol>
  
  <p>I found the output, which is -17891602, but am I correct in assuming this is just a reference to memory that no longer belongs to the program? Because I'm not necessarily getting an error.</p>
  
  <p>It's been a while since I worked with pointers, so I'm getting a but twisted up trying to follow what the code is actually doing. (I know it's simple compared to some stuff you guys are working on, but I'm just getting started learning this stuff   :)   )</p>