home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / std / cplus / 1955 < prev    next >
Encoding:
Text File  |  1993-01-02  |  1.9 KB  |  52 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
  3. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  4. Subject: Re: Compiler should generate virtual destructors
  5. Message-ID: <1993Jan3.031032.12747@ucc.su.OZ.AU>
  6. Sender: news@ucc.su.OZ.AU
  7. Nntp-Posting-Host: extro.ucc.su.oz.au
  8. Organization: MAXTAL P/L C/- University Computing Centre, Sydney
  9. References: <1992Dec31.050150.28929@ucc.su.OZ.AU> <9300301.307@mulga.cs.mu.OZ.AU>
  10. Date: Sun, 3 Jan 1993 03:10:32 GMT
  11. Lines: 39
  12.  
  13. In article <9300301.307@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
  14. >maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  15. >
  16. >>I would like to propose that if a class has virtual functions,
  17. >>then any destructor generated by the compiler will be virtual
  18. >>by default.
  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. >>Disadvantage: might slow down destruction a little. Can be
  25. >>fixed by the programmer explicitly declaring a non-virtual
  26. >>destructor.
  27. >
  28. >I think that this situation should cause a compiler warning, rather
  29. >than adding another arbitrary rule in the language for programmers to
  30. >remember. 
  31.  
  32.     What arbitrary rule? Do you mean the rule that says
  33. automatically generated destructors are *non-virtual* :-) ??
  34.  
  35.     The point here is that the forgetful programmer is protected.
  36.  
  37. >[Off the topic, another situation that should have a required warning
  38. >is the (void *) to (T *) conversion. 
  39.  
  40.  
  41.     void *x;
  42.     T* t;
  43.     t=x; // error here, no mere warning
  44.     t=(T*)x; // warning inserted by programmer in the form of (T*)
  45.     t=reinterpret_cast<T*>x; // grepable warning 
  46.  
  47. -- 
  48. ;----------------------------------------------------------------------
  49.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  50.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  51. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  52.