Shape * shapes[100];
int N; // number of Shapes in shapes array
void handler(Point p)
{
Shape *sp;
for(int i = 0; i < N; i++) {
sp = shapes[i];
if ( sp is pointing to a Rectangle that contains p) {
sp->drawRectangle();
} else if ( sp is pointing to a Circle that contains p){
sp->drawCircle();
} ... etc.
}
void handler(Point p)
{
Shape *sp;
for(int i = 0; i < N; i++) {
sp = shapes[i];
if ( sp->contains(p) ) {
sp->draw();
}
}
}