If you're using templates already, and are willing to adapt your class definitions, then this should work:
template <class T>
class BaseClass {
public:
virtual bool equals(T* other) = 0;
};
template <class T>
class ChildClass : public BaseClass<ChildClass<T> > {
public:
typedef ChildClass<T> thistype;
virtual bool equals(thistype* other) {
bool result(false);
return result;
}
};
Note how the definition of the child class passes its own type down to the base class as a parameter, and thereby defines the argument type of the function
equals()
.