- Execute the == operator as a function of free standing.
- Ask him to call a virtual method for one of the arguments (for example, IsEqual ())
It brings you to what you have.
Derived1::IsEqual(const Base& base)
Called. From here you have several options
- Use RTTI for dynamic_cast <> base to Derived1
If the number of derivatives is small and of course you can implement
virtual bool Base::IsEqualToDerived(const Derived1& d) {return false};
virtual bool Base::IsEqualToDerived(const Derived2& d) {return false};
like virtual methods. In Derived1, you override and compare for real.
source
share