I have a polymorphic set of classes, and I want to have a virtual comparison function. Right now each of the derived classes has a function that looks something like this:
Is it possible to eliminate the dynamic_cast, or am I stuck with it?Code:bool
DerivedClass::Compare( const BaseClass* B ) const
{
if( const DerivedClass* derived = dynamic_cast<const DerivedClass*>(B) )
return details_ == derived->details_ ;
return false ;
}