class Shape
{
virtual void Draw() = 0; // pure virtual function
};
class Circle : public Shape
{
virtual void Draw()
{
// draw shape as a circle
}
};
class Rectangle : public Shape
{
virtual void Draw()
{
// draw shape as a rectangle
}
};
class Triangle : public Shape
{
void Draw()
{
// draw shape as a triangle
}
};
void drawShapes(std::list<Shape*> shapes)
{
std::list<Shape*>::iterator pShape = shapes.begin();
std::list<Shape*>::iterator pEnd = shapes.end();
for ( ; pShape != pEnd; ++pShape)
{
pShape->Draw();
}
}