I have several objects of a Polygon type that just define shapes and I want to store them in a vector that holds Polygons. Polygon has several general methods like getArea() and such, but it is a purely abstract class.
If I have a child of Polygon called Circle, with the method getRadius(), do I need to create a virtual method in Polygon to access that method if it is stored in a vector?
If I expand to more and more shapes, wouldn't creating all those virtual methods in the Polygon declaration (with the associating child method in the child's declaration) be redundant and a waste of space?
Is there another way to inform the compiler that the object I created (of child type) in the Polygon vector of the available child methods without using virtual methods? Or was that kind of the whole point of virtual methods?
I understand how to use virtual methods that the child and parent share, I'm just asking for situations where the parent does not have the method I want to access from the child.