Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Jan 2018 06:22:36 -0800
From:      Mark Millard <marklmi26-fbsd@yahoo.com>
To:        svn-src-head@freebsd.org
Subject:   Re: svn commit: r328430 - head/sbin/devd
Message-ID:  <7F6D11A1-70B6-4A7E-9D5D-93E2C9F8E368@yahoo.com>

next in thread | raw e-mail | index | archive | help
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)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7F6D11A1-70B6-4A7E-9D5D-93E2C9F8E368>