Can you make a C++ generic function?
c++, generics, object, oop, sorting
Solution
I think you are in dire need of Templates! You can write a template function and then write a specialization for the said types to do something specific if the need be.
Problem
Is it possible to create a generic C++ function `foo`? ``` foo(Object bar, Object fred) { //code } ``` in which that if the two objects are recognized, they are compared and a comparison value is returned otherwise some other value is returned to indicate a comparison was not possible? I ask in the case of genericizing a sorting class, in which case you can use this method, and when you derive new objects you want to sort, you add to this foo function, a method on which to sort the new type of Object.