Article View: comp.std.c++
Article #3685Re: Access to private base class?
From: Fergus Henderson
Date: Fri, 15 Mar 1996 02:03
Date: Fri, 15 Mar 1996 02:03
29 lines
1723 bytes
1723 bytes
boukanov@sentef1.fi.uib.no (Igor Boukanov) writes:
>Here the lines from September DWP, 5.2.6.9:
>
>class D : public virtual A, private B {};
>void g()
>{
> D d;
> B* bp = (B*)&d; // cast needed to break protection
>...
>
>Does "cast needed to break protection" mean that in this case it is possible
>to get access to the private base class by simple cast expression?
Yes.
From Stroustrup's book Design and Evolution of C++, page 328:
"The fact that an old-stype cast can be used to gain access to the part of a
representation that is a private base is an unfortunate historical accident."
--
Fergus Henderson WWW: http://www.cs.mu.oz.au/~fjh
fjh@cs.mu.oz.au PGP: finger fjh@128.250.37.3
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Technical Details
Message-ID:
<4iaj1v$2dj@mulga.cs.mu.OZ.AU>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backReferences:
<4ia9bj$atj@ugress.uib.no>Show Full Headers
Complete Article Headers
From: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson) Message-ID: <4iaj1v$2dj@mulga.cs.mu.OZ.AU> X-Original-Date: 15 Mar 1996 02:01:35 GMT Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back Date: 15 Mar 96 02:03:39 GMT Approved: fjh@cs.mu.oz.au Newsgroups: comp.std.c++ Subject: Re: Access to private base class? Organization: Comp Sci, University of Melbourne References: <4ia9bj$atj@ugress.uib.no> Keywords: C++, private class X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMUjQCOEDnX0m9pzZAQGg1wF+OFtXXKugrBAp3ldBZMMvtaQEM8tgXwXw QGSkNR872r5FbLaewYlxss+jkydPJRDX =8/to