Questions tagged «virtual-destructor»




5
虚拟析构函数是否被继承?
如果我有一个带有虚拟析构函数的基类。是否也有派生类声明虚拟析构函数? class base { public: virtual ~base () {} }; class derived : base { public: virtual ~derived () {} // 1) ~derived () {} // 2) }; 具体问题: 1)和2)是否相同?2)是因为其基础而自动虚拟还是“停止”了虚拟性? 如果无关的派生析构函数可以省略吗? 声明派生的析构函数的最佳实践是什么?声明它是虚拟的,非虚拟的还是尽可能省略它?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.