Use-cases of pure virtual functions with body?
问题 I recently came to know that in C++ pure virtual functions can optionally have a body. What are the real-world use cases for such functions? 回答1: The classic is a pure virtual destructor: class abstract { public: virtual ~abstract() = 0; }; abstract::~abstract() {} You make it pure because there's nothing else to make so, and you want the class to be abstract, but you have to provide an implementation nevertheless, because the derived classes' destructors call yours explicitly. Yeah, I know,