Class hierarchies

  class shapelist { 
\fbox{shapelist}
public: shapelist(shape* el=0, shapelist* sl=0) : hd(el), tl(sl) { } shapelist* insert(shape* el) { require( el );
el must exist
if (!hd) hd = el; else return new shapelist(el,this); } shape* head() { return hd; } shapelist* tail() { return tl; } private: shape* hd; shapelist* tl; }

slide: Base class polymorphism