I know there is one case you might want to provide a definition for a pure virtual function. According to effective c++ by Scott Meyers, If you want an abstract class which is used as base class but does not have any other functions, you may need to provide a definition for its pure destructor like this:
class abstract_base_class_do_nothing{
public :
virtual ~abstract_base_class_do_nothing() = 0;
}
abstract_base_class_do_nothing::~abstract_base_class_do_nothing(){}
You provide this because subclass need to call its dtor, and you can't override base class's dtor in derived classes.
Apart to this situation, are there any reasons that you should provide a definition for a pure virtual function? (Of course, overriding it in derived class does NOT count). I mean, even if you provide it, it may never get called by polymorphism anyway.
Thanks!
I just wonder why c++ allow definition for pure virtual functions.