~cpp
class base {
};
class derived : public base {
int compare(derived &ref);
};
int my_comparison_method_for_generic_sort(base &ref1, base &ref2)
{
derived d = dynamic_cast<derived &>(ref1); // rtti used here
// rtti enables the process to throw a bad_cast exception
// if the cast is not successful
return d.compare(dynamic_cast<derived &>(ref2));
}