I am creating a collision detection method between objects, however the objects can be different shapes, and therefore the collision detection method must act very differently when considering two circles rather than two rectangles, for example. I am wondering if there would be a way to implement polymorphically this so that I could, with any two arbitrary objects call obj1.collision(obj2), and the correct code would be executed. Is there a way to implement polymorphism in a way similar to this?
Coming from Java, a not very elegant way to do this would be to use instanceof to determine the correct method to call, but I am not aware of this type of functionality in C++.