title: Object creation on the stack/heap?
body: <p>The following code creates an object on the stack:</p>
  
  <pre><code>Object o;
  </code></pre>
  
  <p>When creating an object on the heap we can use:</p>
  
  <pre><code>Object* o;
  
  o = new Object();
  </code></pre>
  
  <p>rather than:</p>
  
  <pre><code>Object* o = new Object();
  </code></pre>
  
  <p>When we split the heap object-creation over two lines and call the constructor on the second line (<code>o = new object()</code>), does this mean in the first line (<code>Object* o</code>) the pointer was created on the stack? So <code>Object o</code> puts the object on the stack, whereas <code>Object* o</code> puts the pointer to a future object on the stack?</p>
  
  <p>My second question involves if the two lines of code were called outside of a class. I recently read (<a href="https://stackoverflow.com/questions/1169858/global-memory-management-in-c-in-stack-or-heap">Global memory management in C in stack or heap?</a>) that global variables are not contained on the stack/heap but actually another part of memory? If this is the case, would <code>Object* o</code> create a pointer which would sit in this other part of the memory and it points to the heap object?</p>