Final answer:
The implementation of polymorphism in C++ through an abstract class 'FieldOfPlay' and virtual functions is demarcated with derived classes 'Football' and 'Basketball' for calculating field area, and providing specific facility details.
Step-by-step explanation:
To demonstrate the implementation of polymorphism through an abstract class and a virtual function in C++, an abstract class FieldOfPlay will be defined with two derived classes: Football and Basketball. Polymorphism allows the use of a single interface to represent different underlying forms (data types). The virtual function in the abstract class will be used by the derived classes to calculate the area of their respective playing fields, and provide other specific details such as the name of the field, the city it's in, and its capacity.
FieldOfPlay.h
This header file will contain the abstract class FieldOfPlay with a pure virtual function for calculating the area, and virtual functions for getting the name, city, and capacity of the field.
Football.cpp and Basketball.cpp
In the implementation files Football.cpp and Basketball.cpp, we will define methods to calculate the area of a football field (360 feet by 159.9 feet) and a basketball court (94 feet by 50 feet), and implement the getters for the field name, city, and capacity. This information will be specific for Lambeau Field for football and Fiserv Forum for basketball.
Example Usage:
In the main function, an array of pointers to FieldOfPlay will be created that points to instances of Football and Basketball. By calling the virtual function through these pointers, you demonstrate polymorphism, as the program will decide at runtime which function to call based on the object type.