I have a Base class with virtual destructor and final Derived inheritor:
class Base {
public:
virtual ~Base() {
// some impl
}
};
class Derived final : public Base {
public:
virtual ~Derived() override {
// some other impl
}
};
I have the following questions:
~Derived needs virtual specifier?~Derived as final?~Derived() will be a virtual destructor, whether you apply the keyword or not. That's because the base class destructor is virtual.
~Derived() will be a final overrider, because it is a member of a class which is marked final. It does not matter whether you use the final keyword directly on the destructor or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With