home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c++
- Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: pointer comparisons
- Message-ID: <1993Jan9.190136.18834@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <1993Jan5.222300.29535@lucid.com> <1993Jan06.201647.7602@microsoft.com> <1993Jan7.025948.23000@lucid.com>
- Date: Sat, 9 Jan 1993 19:01:36 GMT
- Lines: 44
-
- In article <1993Jan7.025948.23000@lucid.com> jss@lucid.com (Jerry Schwarz) writes:
- > struct X { int i ; } ;
- > struct D : public X {
- > X xInD ;
- > } ;
- >
- This example is not contentious. But:
-
- struct X { virtual int f()=0; };
-
- struct Y : public X { int i; int f(){return i;} };
-
- struct D : public X {
- Y y;
- int j;
- int f(){return j;}
- };
-
- Now this example IS contentious. For an implementation not using
- vtble pointers, the abstract class X might occupy 0 bytes.
-
- Then:
-
- D d;
- d.i=1;
- d.j=2;
-
- X* p1=&d; // base subobject
- X* p2=&d.y; // included object base subobject
- p1==p2; // OH!
- cout<<"1=="<<p1->f();
- cout<<"2=="<<p2->f();
-
- and I dont see how such an implementation could actually work
- UNLESS at least the language require that abstract base
- subobjects occupy at least one byte.
-
- I dont believe this is required by the ARM, clearly it should be.
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-