예제 #1
0
// A function for displaying a geometric object
void displayGeometricObject(GeometricObject &object)
{
  cout << "The area is " << object.getArea() << endl;
  cout << "The perimeter is " << object.getPerimeter() << endl;

  GeometricObject *p = &object;
  Circle *p1 = dynamic_cast<Circle*>(p);
  Rectangle *p2 = dynamic_cast<Rectangle*>(p);

  if (p1 != 0)
  {
    cout << "The radius is " << p1->getRadius() << endl;
    cout << "The diameter is " << p1->getDiameter() << endl;
  }

  if (p2 != 0)
  {
    cout << "The width is " << p2->getWidth() << endl;
    cout << "The height is " << p2->getHeight() << endl;
  }
}
// A function for computing the areas of two geometric objects
bool equalArea(GeometricObject &object1, GeometricObject &object2) {
	return object1.getArea() == object2.getArea();
}
// A function for displaying a geometric object
void displayGeometricObject(GeometricObject &object) {
	cout << "The area is " << object.getArea() << endl;
	cout << "The parimeter is " << object.getPerimeter() << endl;
}