I have two classes
Square which derive from an abstract base class
Shape*array stores pointers to the
Square objects (which include their random position in a 2D grid).
The objective is to determine which shapes in the array overlap and the objects themselves should contain the methods to calculate this. For example, the
Square class would have methods:
bool overlapsWithSquare(Shape s) and
bool overlapsWithCircle(Shape s).
My idea is to construct two for loops which compare each and every shape in the array, however, how would my program know which method to call upon as we don't know what sub-type each Shape object is?
If the actual type was known, I could have two virtual methods in each object,
bool overlaps(...) with different parameters
Square s and