home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / std / cplus / 2104 < prev    next >
Encoding:
Text File  |  1993-01-22  |  2.4 KB  |  67 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!usc!sdd.hp.com!ux1.cso.uiuc.edu!cs.uiuc.edu!sparc0b!pjl
  3. From: pjl@cs.uiuc.edu (Paul Lucas)
  4. Subject: Re: Compiler should generate virtual destructors
  5. Message-ID: <C198n6.JpD@cs.uiuc.edu>
  6. Sender: news@cs.uiuc.edu
  7. Organization: University of Illinois at Urbana-Champaign
  8. References: <1992Dec31.050150.28929@ucc.su.OZ.AU> <lkc2k7INNajv@exodus.Eng.Sun.COM> <harvey.727664973@regina>
  9. Date: Fri, 22 Jan 1993 12:13:53 GMT
  10. Lines: 55
  11.  
  12. In <harvey.727664973@regina> harvey@opl.com (Harvey Reed) writes:
  13.  
  14. >db@argon.Eng.Sun.COM (David Brownell) writes:
  15.  
  16. >>...
  17. >>So, a pair of proposals that I'd be happier to see accepted:
  18.  
  19. >>   (1)    It is an error for a class to have virtual functions and a
  20. >>    nonvirtual destructor.
  21.  
  22.     A warning, perhaps.
  23.  
  24. >>   (2a) C++ compilers don't automagically generate ANYTHING for classes
  25. >>    any more:  constructors, destructors, assignment and address-of
  26. >>    operators, etc.  If such routines are used but not declared and
  27. >>    defined, that is an error.
  28.  
  29.     Would break a large part of th the world (like all struct declarations
  30.     for starters; see below).
  31.  
  32. >I think I would feel a lot better about my C++ compiler if I didn't
  33. >have to make a copy-ctor private/unimplemented (as a safegaurd) just
  34. >because I was afraid that I *might* be accidentally copying an object.
  35. >It would be much better if the compiler simply said it was an error
  36. >to copy without a copy-ctor (or whatever), then the programmer can:
  37.  
  38. >1) remove the need to copy
  39. >2) install the proper method to do the copy
  40.  
  41. >This goes for all the other automagic stuff too! I cringe when I 
  42. >think about automagically adding virtual destructors, even though
  43. >they are most times needed...
  44.  
  45.     Another case for protecting programmers from themselves.  For:
  46.  
  47.         struct Point {
  48.             int x, y;
  49.         };
  50.  
  51.     I don't want to have to write a ctor and assign-op. especially
  52.     when the generated ones would work perfectly.
  53.  
  54.     Whenerver one writes a class, one *has* to ask onesself: Do I
  55.     need a ctor?  An assign-op?  One should have to ask onesself
  56.     this regardless of whether the compiler did the default ones
  57.     for one or not.  If one doesn't, then one is just careless.
  58.  
  59.     The default stuff is for convenience.  In my experience, and I
  60.     would venture others', it's rare to have to forbid copy/assign
  61.     anyway.  Unless you have a good reason to forbid them, who cares?
  62.     Let users copy them.
  63. -- 
  64.     - Paul J. Lucas
  65.       AT&T Bell Laboratories
  66.       Naperville, IL
  67.