Is it a memory leak?
<p>I am new to c++ and I just learned about dynamic memory and memory leaks.</p>

<p>From what I understand, when creating a pointer(<code>int *ptr = new int</code>), and then changing the address that he is pointing, the old address still exist/allocated. 
(please correct me if I am wronge).</p>

<p>so I thought about this:</p>

<pre><code>int *ptr;
ptr = new int;
</code></pre>

<p>first ptr is fill with random(or not?) address, then I change it, so the old one stays?
if I try this code:</p>

<pre><code>int *ptr;
cout &lt;&lt; ptr &lt;&lt; endl ;
ptr = new int;
cout &lt;&lt; ptr &lt;&lt; endl ;
</code></pre>

<p>I get:</p>

<pre><code>0x401a4e
0x6d2d20
</code></pre>

<p>Does it mean that 0x401a4e is part of a memory leak? Or is it released when ptr moves to dynamic memory? How does it work?</p>
