home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / gnu / g / bug / 1837 < prev    next >
Encoding:
Text File  |  1992-11-17  |  2.0 KB  |  54 lines

  1. Newsgroups: gnu.g++.bug
  2. Path: sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tele.nokia.fi!girod
  3. From: girod@tele.nokia.fi (Marc Girod)
  4. Subject: definition of pure virtual destructor
  5. Message-ID: <GIROD.92Nov16123454@node_262d6.tele.nokia.fi>
  6. Sender: gnulists@ai.mit.edu
  7. Reply-To: marc.girod@ntc.nokia.com
  8. Organization: kpd
  9. Distribution: gnu
  10. Date: Mon, 16 Nov 1992 10:34:54 GMT
  11. Approved: bug-g++@prep.ai.mit.edu
  12. Lines: 40
  13.  
  14. Hi netters!
  15.  
  16. I am reading a very interesting book by Scott Meyers, 'Effective C++ -
  17. 50 specific ways to improve your programs and designs', 1992 Addison
  18. Wesley, ISBN 0-201-56364-9.
  19.  
  20. I got so far as Item 14 page 47, where I found an advice to (under
  21. some circumstances) declare a pure virtual destructor. Nothing
  22. actually new there so far, but the author further notes that 'you must
  23. provide a definition for the pure virtual destructor'.
  24.  
  25. That was new to me, but sounds very reasonable. Some small surprise
  26. because I happen never to have experimented a crash because of failing
  27. to do so. I try, and ... g++ refuses it!
  28.  
  29. The example:
  30. ------------------------------------------------------------
  31. class foo {
  32. public:
  33.   virtual ~foo() = 0;
  34. };
  35.  
  36. foo::~foo() {}
  37. ------------------------------------------------------------
  38. The result:
  39. GNU C++ version 2.2.2 (sparc) compiled by GNU C version 2.2.2.
  40. pure.C: In method `foo::~foo ()':
  41. pure.C:6: redefinition of `foo::~foo ()'
  42. pure.C:3: here is the previous declaration of `foo::~foo ()'
  43.  
  44. Sorry if this had been reported already!
  45. Regards!
  46. --
  47. +-----------------------------------------------------------------------------+
  48. | Marc Girod - Nokia Telecommunications       Phone: +358-0-511 7703          |
  49. | TL4E - P.O. Box 12                            Fax: +358-0-511 7432          |
  50. | SF-02611 Espoo 61 - Finland              Internet: marc.girod@ntc.nokia.com |
  51. |    X.400: C=FI, A=Elisa, P=Nokia Telecom, UNIT=TRS, SUR=Girod, GIV=Marc     |
  52. +-----------------------------------------------------------------------------+
  53.  
  54.