title: c++ array of pointers and memory address allocation
body: <p>Can someone explain how an array of pointers implementation of c++ dynamically?</p>
  
  <p>Is the below code correct?</p>
  
  <p>If so,  </p>
  
  <pre><code> int *ptr[5]; 
  
   for (int i = 0; i &lt; 5; i++)
    {
  
    int size = 2;
  
    ptr[i] = new int [size] ;
  
   //*(ptr + i) = new int[size]; this is the same as above line
  
    cout &lt;&lt; &amp;ptr[i] &lt;&lt; endl;   ----------&gt; line 1
    cout &lt;&lt; ptr[i] &lt;&lt; endl; -----------&gt; line 2
    }
  </code></pre>
  
  <p>What is actually printing in line 1 and 2 ?</p>
  
  <p>this is the addresses i get for line 1</p>
  
  <pre><code>0x7fff88f805d0
  0x7fff88f805d8
  0x7fff88f805e0
  0x7fff88f805e8
  0x7fff88f805f0
  </code></pre>
  
  <p>this is the addresses I get for line 2</p>
  
  <pre><code>0x55f946348ef0
  0x55f946349330
  0x55f946349360
  0x55f946349390
  0x55f9463493c0
  </code></pre>
  
  <p>Can somebody explain this whole mess of pointer arrays.</p>