home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13393 < prev    next >
Encoding:
Text File  |  1992-09-08  |  1.4 KB  |  35 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!taumet!steve
  3. From: steve@taumet.com (Steve Clamage)
  4. Subject: Re: Novice question
  5. Message-ID: <1992Sep8.163541.24845@taumet.com>
  6. Organization: TauMetric Corporation
  7. References: <1992Sep1.213224.7550@actrix.gen.nz> <79153@ut-emx.uucp> <1992Sep5.030224.13196@lut.ac.uk>
  8. Date: Tue, 8 Sep 1992 16:35:41 GMT
  9. Lines: 24
  10.  
  11. J.March@lut.ac.uk writes:
  12.  
  13. >I'm getting quite few "warning: assignment to this (anachronism)" messages
  14. >from my compiler.  I do actually want to do this, so how do I let my
  15. >compiler know that I *really* mean it.
  16.  
  17. It is not legal to assign to "this", and you really DON'T want to do it.
  18.  
  19. The original version of C++ allowed assignment to "this" to permit a
  20. class to do its own memory management.  This technique was very unsafe,
  21. and subject to errors that were easy to make but very hard to find.
  22.  
  23. In 1989, C++ introduced overloading "new" and "delete" to allow a class
  24. to do its own memory management.  This is much safer than the older
  25. technique.  At the same time, assignment to "this" was made obsolescent.
  26.  
  27. Modern C++ compilers no longer support assignment to "this", since
  28. there is no valid reason to want to do it.  Programmers who want to 
  29. assign to "this" generally have a misunderstanding about what the
  30. effect would be if it were allowed.
  31. -- 
  32.  
  33. Steve Clamage, TauMetric Corp, steve@taumet.com
  34. Vice Chair, ANSI C++ Committee, X3J16
  35.