title: What's the difference between data stored in global variables and data stored in the heap?
body: <pre><code>int globalInt = 1; 
  
  int main(){
      int* heapInt = new int(1);
  }
  </code></pre>
  
  <p>What is the difference between globalInt and heapInt? I know that what heapInt points to is in the heap, and I know that globalInt goes into some global data storage, but what is the difference? Why use one over the other? </p>
  
  <p>Thank you in advance for any help. </p>