Polymorphism C++

CPolygon * ppoly1 = new CRectangle;


DOes it mean poly1 can either point to type of Cpolygon or Crectangle?
Yes (Assuming CRectangle is derived from CPolygon), this is because CRectagle IS a CPolygon. A pointer to a type T can point to any object that is derived from type T.
Topic archived. No new replies allowed.