🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2054

Re: Inheritance and references to pointers

#2054
From: Sam Fenster
Date: Wed, 27 Sep 1995 17:42
32 lines
2094 bytes
> Jean-Rene Bouvier <jr@isoit109.bbn.hp.com> writes:
>> 1. is my understanding correct (i.e. that a DerviedObject*& cannot be
>> passed in lieu of an Object*&) ?

martelli@cadlab.cadlab.it (Alex Martelli) writes:
> It would violate type-safety.  It may be easier to see with pointers to
> pointers:

> B b;
> void tricky(B ** pointer_to_pointer)
> {*pointer_to_pointer = &b;}
> 
> void ingenue()
> {D d;  D* pd = &d;  tricky(&pd);  pd->aMethodOnlyDhadAnd_NOT_B();}

> This is, in a way, related to of the old problem that a bag-of-apples
> is-NOT-a bag-of-fruit (even if an apple is-A fruit) *under mutation*
> (because if you passed it to a function treating it as bag-of-fruit, it
> could insert in it a banana, thus violating semantic constraints [class
> invariants] of bag-of-apples).  [_that_, in turn, can be more abstractly
> related to the problem that a circle is-NOT-an ellipse *under mutation*,
> because a rescale(mX,mY) would violate the semantic symmetry constraint of
> class circle...].  The presence of mutators makes is-A determinations far
> from intuitive sometimes...!

The fact that `D **' is-NOT-a `B **' is closely related to the fact that
`B **' is-NOT-a `const B **'.  Both pairs fail because the referent of the
latter item can be mutated in ways not allowed by the former item.
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <FENSTER.95Sep27121616@shadow.cs.columbia.edu>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <445k3k$18p@isoit109.bbn.hp.com> <martelli.812100227@cadlab>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 27 Sep 95 17:42:30 GMT
Approved: fjh@cs.mu.oz.au
From: fenster@cs.columbia.edu (Sam Fenster)
Newsgroups: comp.std.c++
Subject: Re: Inheritance and references to pointers
X-Original-Date: 27 Sep 1995 16:16:16 GMT
Organization: Columbia University Department of Computer Science
Message-ID: <FENSTER.95Sep27121616@shadow.cs.columbia.edu>
References: <445k3k$18p@isoit109.bbn.hp.com> <martelli.812100227@cadlab>
In-Reply-To: martelli@cadlab.cadlab.it's message of 26 Sep 1995 15:13:36 GMT