如果你的基类将以多态方式使用,你必须声明 它的析构函数虚拟,所以你不需要虚拟纯虚的 功能。只需声明析构函数本身是纯虚拟的: virtual~base()= 0If your base class is going to be used polymorphically, you must declareits destructor virtual anyway, so you don''t need a "dummy" pure virtualfunction. Just declare the destructor itself pure virtual:virtual ~base() = 0 当然! 这个解决方案负责我现在正在处理 的情况,但如果有的话,怎么会这样做?/ b 清理在基类级别上做什么? 使用上面的解决方案,必须在每个中调用一些 base :: cleanup()函数衍生的 析构函数吧? 符文Of course!This solution takes care of the case I''m working onright now, but how would one do this if there weresome cleaning up to do on the base class level?With the above solution one would have to call somebase::cleanup() function in each of the deriveddestructors, right?Rune 这篇关于抽象类的实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-22 19:14