#include #include #include using namespace std; class Shape { public: Shape() {}; void setColor() { cout << " Shape::setColor() called "<< endl; } void Draw() { cout << " Shape::Draw() called "<< endl; } //.. }; class Rectangle : public Shape { public: void Draw() { cout << " Rectangle::Draw() called "<< endl; } }; class Oval : public Shape { public: void Draw() { cout << " Oval::Draw() called "<< endl; } }; class RoundRect : public Shape { public: void Draw() { cout << " RoundRect::Draw() called "<< endl; } }; int main () { vector vecshape; // vector with base-class pointers // add some concrete shapes vecshape.push_back( new Rectangle()); vecshape.push_back( new Oval()); vecshape.push_back( new Rectangle()); vecshape.push_back( new RoundRect()); vecshape.push_back( new Oval()); vecshape.push_back( new Oval()); for ( int i=0; isetColor( ); vecshape[i]->Draw( ); } }