🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1210

definition of pure virtual destructor

#1210
From: Marc Girod
Date: Mon, 16 Nov 1992 10:34
39 lines
2069 bytes
Hi netters!

I am reading a very interesting book by Scott Meyers, 'Effective C++ -
50 specific ways to improve your programs and designs', 1992 Addison
Wesley, ISBN 0-201-56364-9.

I got so far as Item 14 page 47, where I found an advice to (under
some circumstances) declare a pure virtual destructor. Nothing
actually new there so far, but the author further notes that 'you must
provide a definition for the pure virtual destructor'.

That was new to me, but sounds very reasonable. Some small surprise
because I happen never to have experimented a crash because of failing
to do so. I try, and ... g++ refuses it!

The example:
------------------------------------------------------------
class foo {
public:
  virtual ~foo() = 0;
};

foo::~foo() {}
------------------------------------------------------------
The result:
GNU C++ version 2.2.2 (sparc) compiled by GNU C version 2.2.2.
pure.C: In method `foo::~foo ()':
pure.C:6: redefinition of `foo::~foo ()'
pure.C:3: here is the previous declaration of `foo::~foo ()'

Sorry if this had been reported already!
Regards!
--
+-----------------------------------------------------------------------------+
| Marc Girod - Nokia Telecommunications       Phone: +358-0-511 7703          |
| TL4E - P.O. Box 12                            Fax: +358-0-511 7432          |
| SF-02611 Espoo 61 - Finland              Internet: marc.girod@ntc.nokia.com |
|    X.400: C=FI, A=Elisa, P=Nokia Telecom, UNIT=TRS, SUR=Girod, GIV=Marc     |
+-----------------------------------------------------------------------------+
Technical Details
Message-ID: <GIROD.92Nov16123454@node_262d6.tele.nokia.fi>
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tele.nokia.fi!girod

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tele.nokia.fi!girod
From: girod@tele.nokia.fi (Marc Girod)
Subject: definition of pure virtual destructor
Message-ID: <GIROD.92Nov16123454@node_262d6.tele.nokia.fi>
Sender: gnulists@ai.mit.edu
Reply-To: marc.girod@ntc.nokia.com
Organization: kpd
Distribution: gnu
Date: Mon, 16 Nov 1992 10:34:54 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 40