title: dynamic memory allocation- why there is no "delete" at the end of the program?
body: <p>I have 2 questions regarding to the program below:
  1. Does the program create only the elements(type rectangle and hexagon) as dynamic, or also the pointers to them are dynamic?</p>
  
  <p>2.why the program doesn't have a delete at the end. for example something like this:(if I assume correctly that only the elements are dynamic..)</p>
  
  <pre><code>for(i=0;i&lt;3;i++)
      delete shapeArray[i];
  </code></pre>
  
  <p>Thank you very much,this website helps me a lot with things that my teachers can't help!
  Shiran</p>
  
  <p>the program is:</p>
  
  <pre><code> int main()
  {
   // Create array of pointers to Shapes of various types.
   const int NUM_SHAPES = 3;
  
   Shape * shapeArray[] = { new Hexagon(),
   new Rectangle(),
   new Hexagon()
   };
  
   // Set positions of all the shapes.
   int posX = 5, posY = 15;
   for (int k = 0; k &lt; NUM_SHAPES; k++)
       {
   shapeArray[k]-&gt;setPosition(posX, posY);
   posX += 10;
   posY += 10;
  };
  
   // Draw all the shapes at their positions.
   for (int j = 0; j &lt; NUM_SHAPES; j++)
  {
   shapeArray[j]-&gt;draw();
   }
  
   return 0;
   }
  </code></pre>