and this is how it looks like:
Color *yellow = new Color( 1.0, 1.0, 0.0 ); // yellow
Color *green = new Color( 0.0, 1.0, 0.0 ); // green
cylinder *c1 = new cylinder (1.,2.); // default-colored cylinder
cylinder *c2 = new cylinder (1.,2.,*green); // green cylinder
cube *c3 = new cube (1.,*yellow); // yellow cube
cylinder of radius 1 height 2 Color ( 0, 0, 0 )
cylinder of radius 1 height 2 Color ( 0, 1, 0 )
cube of length 1 Color ( 1, 1, 0 )
Close, very close, but not yet quite ok. It is ok in the above example because
c1,c2,and c3 are pointers to cube and cylinder, respectively. Were they pointers to the parent class “body”, it would not work. We will of course define a operator<< for body, but this function wouldn’t know whether to access cube’s or a cylinder’s “private parts” (even if it were allowed to, which it isn’t). We will need to do this through member functions again...