home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / std / cplus / 1960 < prev    next >
Encoding:
Internet Message Format  |  1993-01-03  |  1.7 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!caen!uflorida!max.fiu.edu!serss0!feathers
  2. From: feathers@serss0 (Michael Feathers)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Compiler should generate virtual destructors
  5. Message-ID: <C0Ayt4.263@fiu.edu>
  6. Date: 4 Jan 93 00:03:04 GMT
  7. References: <1992Dec31.050150.28929@ucc.su.OZ.AU>
  8. Sender: news@fiu.edu (Usenet Administrator)
  9. Organization: Florida International University, Miami
  10. Lines: 30
  11.  
  12. In article <1992Dec31.050150.28929@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  13. >I would like to propose that if a class has virtual functions,
  14. >then any destructor generated by the compiler will be virtual
  15. >by default.
  16. >
  17. >(The suggestion was first read by me in a paper of Markku Sakkinen,
  18. >who claims it was not his idea originally either.)
  19. >
  20. >Advantages: much safer, ensures correct deletion of objects
  21. >by default.  Removes a source of bugs. Removes the reminder
  22. >that its wise to do this from the FAQ.
  23.  
  24. This would be a way in which a function within the source code would be
  25. virtual without the keyword 'virtual' having been used on it or a function of
  26. the same name in an inherited class.  That would bother me as a consistency 
  27. issue.
  28.  
  29. >Disadvantage: might slow down destruction a little. Can be
  30. >fixed by the programmer explicitly declaring a non-virtual
  31. >destructor.
  32.  
  33. The only way to make something explicity non-virtual would be the absence
  34. of the 'virtual' keyword, unless we add a new keyword <shudder>.
  35.  
  36. If the destructor is going to be made virtual by that rule, there is no
  37. need to declare it virtual.  But we can not make it explicitly non-virtual
  38. unless the virtual keyword is an option.
  39.  
  40.  
  41. Michael Feathers  [feathers@fiu.edu]      main () { main (); }
  42.