示例22 class Square public Shapes private int length public: void draw o //在派生类中重新定义 cout<<"绘制正方形\ void main() Circle c 调用 Shapes Square s 的draw0)方 Shapes* ptri 法 ptr =&ci ptr->draw)i ptr &s ptr->drawoi 6 北大青鸟6 示例 2-2 class Square : public Shapes { private: int length; public: void draw() //在派生类中重新定义 { cout << "绘制正方形\n"; } }; void main() { Circle c; Square s; Shapes* ptr; ptr = &c; ptr->draw(); ptr = &s; ptr->draw(); } 调用Shapes 的draw()方 法