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

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!stanford.edu!lucid.com!lucid.com!jss
  3. From: jss@lucid.com (Jerry Schwarz)
  4. Subject: Re: Pointer comparisons
  5. Message-ID: <1992Dec23.182456.17185@lucid.com>
  6. Sender: usenet@lucid.com
  7. Reply-To: jss@lucid.com (Jerry Schwarz)
  8. Organization: Lucid, Inc.
  9. References: <1992Dec16.202711.22367@bcrka451.bnr.ca> <BzDs2x.wA@frumious.uucp> <1992Dec17.151642.9954@bcrka451.bnr.ca> <1992Dec19.001851.22116@microsoft.com>
  10. Date: Wed, 23 Dec 92 18:24:56 GMT
  11. Lines: 38
  12.  
  13. Jim Adcock is advocating that under some circumstances it
  14. is ok for a compiler to put two A objects at the same location.
  15.  
  16. His example is
  17.  
  18. |> class A {};
  19. |> 
  20. |> class B : public A
  21. |> {
  22. |> public:
  23. |>     A a;    
  24. |> };
  25. |> 
  26.  
  27.     B b ;
  28.  
  29. Where he claims it is ok for b.a and (B&)a to compare equal.
  30.  
  31. I don't agree, but I'm wondering exactly what criteria he is applying.
  32. Does anything go for A's.  E.g.
  33.  
  34.     void f() {
  35.         A a1, a2 ;  // can &a1==&a2 
  36.         ... ; 
  37.         }
  38.  
  39. Is it only ok for "empty" classes? How about 
  40.  
  41.     struct D { int i; int j ; } ;
  42.  
  43.     void f() {
  44.         D d1, d2 ;
  45.         ... d1.i ... d2.j ...  // never use d1.j or d2.i 
  46.             }
  47.  
  48. Can &d1==&d2.
  49.  
  50.   -- Jerry Schwarz
  51.