svn commit: r328430 - head/sbin/devd

Mark Millard marklmi26-fbsd at yahoo.com
Fri Jan 26 14:32:50 UTC 2018


Warner Losh imp at bsdimp.com wrote on
Fri Jan 26 06:02:04 UTC 2018 :

> It's a flaw in C++ that you have a choice here. All dtors should  be
> virtual because you never know when you'll have new derived classes and
> have to hunt down a hard-to-find bug because you didn't go back and make it
> virtual.

The "C++ Coding Standards" book described it this way:

QUOTE
To delete, or not to delete, that is the question: if deleting through
a pointer to base Base should be allowed, then Base's destructor must be
public and virtual. Otherwise, it should be protected and nonvirtual.
. . .
Corollary: Always write a destructor for a base class, because the
implicitly generated one is public and nonvirtual.
END QUOTE

See page 90 for more.

===
Mark Millard
marklmi at yahoo.com
( markmi at dsl-only.net is
going away in 2018-Feb, late)



More information about the svn-src-head mailing list