8-6 请编写一个抽象类Shape,在此基础上派生出类Rectangle和Circle,二者都有计算对象面积的函数getArea()、计算对象周长的函数getPerim()。
在例8-6的基础上,通过继承Rectangle 得到一个新的类 Square,然后在 Shape 中增加一个函数int getVertexCount() const用来获得当前图形的顶点个数,用以下几种方法分别实现,并体会各自的优劣。
(1)使用dynamic_cast 实现 Shape::getVertexCount函数。
(2)使用typeid 实现Shape::getVertexCount 函数。
(3)将Shape::getVertexCount声明为纯虚函数,在派生类中给出具体实现。