From -5985251652345379082
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fc772,cda54862ecb4a41f
X-Google-Attributes: gidfc772,public
X-Google-Thread: f78e5,cda54862ecb4a41f
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2001-08-28 22:02:08 PST
Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!paloalto-snf1.gtei.net!chcgil2-snh1.gtei.net!denver-snf1.gtei.net!news.gtei.net!namche.sun.com!news2me.EBay.Sun.COM!sunnews1.Eng.Sun.COM!engnews1.eng.sun.com!taumet!clamage
From: Steve Clamage <Stephen.Clamage@Sun.COM>
Newsgroups: comp.std.c++,comp.lang.c++.moderated
Subject: Re: storage order of inherited classes
Date: 29 Aug 2001 04:55:29 GMT
Organization: Sun Microsystems Inc., Mountain View, CA
Lines: 41
Approved: stephen.clamage@sun.com (comp.std.c++)
Message-ID: <Pine.SOL.4.33.0108281010270.6075-100000@taumet>
References: <MpMh7.6544$3f.1248650@news2-win.server.ntlworld.com>
 <5pqjot40to3q1rcrhokquq3e6k9s1sv2k3@4ax.com>
NNTP-Posting-Host: taumet.eng.sun.com
X-NNTP-Posting-Host: netlab.cs.rpi.edu
X-Original-Date: Tue, 28 Aug 2001 10:15:32 -0700
X-Submission-Address: c++-submit@netlab.cs.rpi.edu
X-Auth: PGPMoose V1.1 PGP comp.lang.c++.moderated
	iQBVAwUAO4w/1UHMCo9UcraBAQGU8QH/WvKXu1cqjnLWqJoZAK13F+f6Z0USyQZs
	Le2WIgo+00LmzC/TXYkgxd/LGeRKocqs7eYczGWhtg+wXt9H3cA3GQ==
	=ZJlo
X-Approved-For-Group: jep@eagle.lhup.edu comp.lang.c++.moderated
Content-Length: 1569
X-Status: $$$$
X-UID: 0000000001
Originator: clamage@taumet
Xref: archiver1.google.com comp.std.c++:7221 comp.lang.c++.moderated:25575


On 28 Aug 2001, Jack Klein wrote:
>
> A base class appears before any of the additional data items added in
> a derived class in a case like this.

Although that is a common layout scheme, it is certainly not a
requirement.

> Otherwise it would not be
> possible for a pointer to a base class to point to a derived class
> object.  The first sizeof(base class) bytes of the derived class must
> be the instance of the base class in the derived class.

If that were true, how would you implement multiple inheritance?
If more than one direct base class has non-zero size, you can't
put all of them at the beginning of the object!

There is no requirement that Derived* and Base* refer to the
same address. The requirement is that a Derived* converted to
a Base* then points to the Base portion of the object. Pointer
conversions are allowed to involve runtime code that changes
the bits in the pointer value.  In the case of multiple
inheritance and virtual base classes, the conversion MUST
involve a change.

-- 
Steve Clamage, stephen.clamage@sun.com



      [ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
      [ about comp.lang.c++.moderated. First time posters: do this! ]

[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]




