home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / std / cplus / 1911 < prev    next >
Encoding:
Text File  |  1992-12-24  |  2.0 KB  |  43 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!microsoft!hexnut!jimad
  3. From: jimad@microsoft.com (Jim Adcock)
  4. Subject: Re: Pointer comparisons
  5. Message-ID: <1992Dec24.011254.1982@microsoft.com>
  6. Date: 24 Dec 92 01:12:54 GMT
  7. Organization: Microsoft Corporation
  8. References: <BzDs2x.wA@frumious.uucp> <1992Dec17.151642.9954@bcrka451.bnr.ca> <1992Dec18.181029.1061@taumet.com>
  9. Lines: 32
  10.  
  11. In article <1992Dec18.181029.1061@taumet.com> steve@taumet.com (Steve Clamage) writes:
  12. |Right.  In the C Standard, it is stated explicitly that two pointers
  13. |of the same type which compare equal point to the same object or
  14. |function.  There is no such statment for C++ in the ARM or in the
  15. |current C++ Committee working draft.
  16.  
  17. What needs to be made clear includes what is meant by "point to the
  18. same object."  As in my example the pointers *do* point to the same object,
  19. and they do compare equal.  It's just that one pointer refers to an
  20. enclosing object, and one pointer the enclosed object.  Same object,
  21. just not identically the same object.  
  22.  
  23. Also needs to be clarified all the different implications.  If two
  24. pointers which compare equal point to the same object, do two pointers
  25. to 'the same object' compare equal?  Do two pointers not comparing 
  26. equal not point to the same object?  Do two pointers not to the same
  27. object not compare equal?  These issues are much more obvious in C
  28. than in C++.
  29.  
  30. Ultimately, I do not believe worrying about these pointer "details" 
  31. is very important unless one first decides what properties of object
  32. identity C++ objects must have and why.  The current permission of
  33. C++ compilers to create temporaries at will kind of blows object identity
  34. out of the water.  Why worry about pointer equality, then?
  35.  
  36. One thing you might want to consider is dividing C++ objects into two categories
  37. -- those with and without virtual functions or virtual bases.  Then 
  38. just require "C" rules on those without virtualness.  But require some
  39. reasonable "object oriented" rules of object identity for those with 
  40. virtualness.
  41.  
  42. Alternately, just leave it implementation defined ;-)
  43.