title: Suppose I declare an int but don't initialize it; what value is it? Can someone clear this up for me?
body: <p>Can someone help me get a better understanding of creating variables in <code>C++</code>? I'll state my understanding and then you can correct me. </p>
  
  <hr>
  
  <pre><code>int x; 
  </code></pre>
  
  <p>Not sure what that does besides declare that <code>x</code> is an integer on the stack.</p>
  
  <hr>
  
  <pre><code>int x = 5; 
  </code></pre>
  
  <p>Creates a new variable <code>x</code> on the stack and sets it equal to <code>5</code>. So empty space was found the stack and then used to house that variable.</p>
  
  <pre><code>int* px = new int;
  </code></pre>
  
  <p>Creates an anonymous variable on the heap. <code>px</code> is the memory address of the variable. Its value is <code>0</code> because, well, the bits are all off at that memory address.</p>
  
  <pre><code>int* px = new int;
  *px = 5;
  </code></pre>
  
  <p>Same thing as before, except that the value of the integer at memory address <code>px</code> is set to 5. (Does this happen in 1 step???? Or does the program create an integer with value 0 on the heap and <strong>then</strong> set it to 5?</p>
  
  <p>I know that everything I wrote above probably sounds naive, but I really am trying to understand this stuff.</p>