home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / std / cplus / 2020 < prev    next >
Encoding:
Text File  |  1993-01-09  |  1.6 KB  |  57 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: pointer comparisons
  5. Message-ID: <1993Jan9.190136.18834@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: <1993Jan5.222300.29535@lucid.com> <1993Jan06.201647.7602@microsoft.com> <1993Jan7.025948.23000@lucid.com>
  10. Date: Sat, 9 Jan 1993 19:01:36 GMT
  11. Lines: 44
  12.  
  13. In article <1993Jan7.025948.23000@lucid.com> jss@lucid.com (Jerry Schwarz) writes:
  14. >    struct X { int i ; } ;
  15. >    struct D : public X {
  16. >        X xInD ;
  17. >    } ;
  18. >
  19.     This example is not contentious. But:
  20.  
  21.     struct X { virtual int f()=0; };
  22.  
  23.     struct Y : public X { int i; int f(){return i;} };
  24.  
  25.     struct D : public X {
  26.         Y y;
  27.         int j;
  28.         int f(){return j;}
  29.     };
  30.  
  31. Now this example IS contentious. For an implementation not using
  32. vtble pointers, the abstract class X might occupy 0 bytes.
  33.  
  34. Then:
  35.  
  36.     D d;
  37.     d.i=1;
  38.     d.j=2;
  39.     
  40.     X* p1=&d; // base subobject
  41.     X* p2=&d.y; // included object base subobject
  42.     p1==p2; // OH!
  43.     cout<<"1=="<<p1->f();
  44.     cout<<"2=="<<p2->f();
  45.  
  46. and I dont see how such an implementation could actually work
  47. UNLESS at least the language require that abstract base
  48. subobjects occupy at least one byte.
  49.  
  50. I dont believe this is required by the ARM, clearly it should be.
  51.  
  52. -- 
  53. ;----------------------------------------------------------------------
  54.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  55.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  56. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  57.