------------------------------------------------------------------------------
MC logo
Compound Shape Class
[^] Code Examples
------------------------------------------------------------------------------
<<Shape Implementations compound.h Compound Shape Implementation>>
#ifndef _COMPOUND_H_
#define _COMPOUND_H_ 1

#include "shape.h"

//
// This file contains a class for compound Shapes which are collections
// of other Shapes.
//
class CompoundShape: public Shape
{
    protected:
        int numfig;             // Number of Shapes.
        int capacity;           // Storage capacity.
        Shape **figs;           // List of Shapes.
    public:
        CompoundShape(int x = 0, int y = 0): Shape(x, y) 
        {
                numfig = capacity = 0;
                figs = NULL;
        }
        ~CompoundShape() { delete figs; }

        // Add a Shape to the list.
        void add(Shape *f);

        // Draw them all.
        virtual void draw(Drawable &d);
};
#endif
<<Shape Implementations Compound Shape Implementation>>