class Rect; bool intersect( Rect* ); bool intersect( Ellipse* ); bool intersect( Polygon* ); ... #### #include using namespace std; class Shape { public: virtual ~Shape(){}; }; class Polygon : public Shape { }; class Circle : public Shape { }; void ShowType(Shape *obj) { cout << "Shape" << endl; } void ShowType(Polygon *obj) { cout << "Polygon" << endl; } void ShowType(Circle *obj) { cout << "Circle" << endl; } int main() { Shape *shape; shape = new Polygon(); ShowType(shape); shape = new Circle(); ShowType(shape); } #### Shape Shape #### void ShowType(Shape *obj) { if (dynamic_cast(obj)) ShowType(dynamic_cast(obj)); else if (dynamic_cast(obj)) ShowType(dynamic_cast(obj)); else cout << "Shape" << endl; } #### Polygon Circle