Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A12-4-1 - Does it apply to private inheritance?
#1
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.


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!
Reply


Messages In This Thread
A12-4-1 - Does it apply to private inheritance? - by cgpzs - 15-03-2022, 12:59 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)