C++ supports polymorphism through virtual functions. The selection of an appropriate function is done at run time, which is called late or dynamic binding. The particular function to invoke is determined at run-time based on the specific type of object. This mechanism is possible only through the use of pointers to objects.
In this lab, you have to implement the following class hierarchy.
Shape is the base class. It only provides the interfaces, which the derived classes, i.e. Rectangle and Triangle should implement. The three functions which are common to the Rectangle and Triangle class are
- GetArea(): A pure virtual function
- Draw(): A virtual function