Hi,
Rule A12-4-1 says:
"Destructor of a base class shall be public virtual, public override or protected non-virtual."
Does it apply in the context of private inheritance? In that case, it's not possible to obtain a pointer to the Base class, therefore mitigating the risks the rule is trying to prevent from.
The goal here is to be able to create both Base and Derived objects; therefore Base cannot have a protected non-virtual destructor. A public virtual destructor would come with performance penalties.
Thanks!
Rule A12-4-1 says:
"Destructor of a base class shall be public virtual, public override or protected non-virtual."
Does it apply in the context of private inheritance? In that case, it's not possible to obtain a pointer to the Base class, therefore mitigating the risks the rule is trying to prevent from.
Code:
class Base // A12-4-1 violated here?
{};
class Derived final : private Base
{};
The goal here is to be able to create both Base and Derived objects; therefore Base cannot have a protected non-virtual destructor. A public virtual destructor would come with performance penalties.
Thanks!