title: Can a pointer to base point to an array of derived objects?
body: <p>I went to a job interview today and was given this interesting question.</p>
  
  <p>Besides the memory leak and the fact there is no virtual dtor, why does this code crash?</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  //besides the obvious mem leak, why does this code crash?
  
  class Shape
  {
  public:
      virtual void draw() const = 0;
  };
  
  class Circle : public Shape
  {
  public:
      virtual void draw() const { }
  
      int radius;
  };
  
  class Rectangle : public Shape
  {
  public:
      virtual void draw() const { }
  
      int height;
      int width;
  };
  
  int main()
  {
      Shape * shapes = new Rectangle[10];
      for (int i = 0; i &lt; 10; ++i)
          shapes[i].draw();
  }
  </code></pre>