From 5062398155150984443
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,8c9f1307b83ac2db
X-Google-Attributes: gidf78e5,public
From: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: Q: virtual functions not overridable anymore?
Date: 1997/09/11
Message-ID: <5v719t$7g1@mulga.cs.mu.OZ.AU>#1/1
X-Deja-AN: 271680439
References: <01bcb109$1e790180$433574cf@worldnet.worldnet.att.net> <3404A0AE.6F7E@Eng.Sun.COM> <5uimip$l56@bgtnsc03.worldnet.att.net> <340D93AA.643A@Eng.Sun.COM> <01bcb951$ea80a440$909c389d@mtayler> <ocr4t7zlk2o.fsf@ml.com> <34166C9E.1882@pratique.fr>
X-Original-Date: 10 Sep 1997 20:52:13 GMT
Organization: Comp Sci, University of Melbourne
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBNBhNa0y4NqrwXLNJAQGxkAIAgR9lO/9cp7pDWF6xY0h3lv/g2cdbeuz1 rzhrva3gGixP/eDyB7FhdqBg8gsZEnuPzhVg3uIs5o5mZWqhm6hjGQ== =DU/h
Newsgroups: comp.std.c++
Originator: austern@isolde.mti.sgi.com


Valentin Bonnard <bonnardv@pratique.fr> writes:

>Colin Rafferty <craffert@ml.com> writes:
>
>> Michael B Taylor writes:
>> 
>> > Maybe I missing something about this whole thread, but it seems to me that
>> > the desire to declare a virtual method "final" in some derived class is the
>> > same as the desire to declare a method in a class non-virtual.
>> > [[...Example defining a class `foo' by inheriting from a class `bar'
>> > which has a virtual member `spam()'...]]
>> > I'm forced to have spam virtual. 
>> 
>> You are only forced into doing this because you have derived from
>> `bar'.  This is your choice.  Since `foo' "is-a" `bar', then it must
>> have all the same properties of `bar'.  One of these is that its member
>> function `spam' is overridable by subclasses.
>
>You invented a new substitution principle (the Rafferty 
>substitution principle ?); I never saw it in OO litterature.

As in Rafferty's Rules? ;-) 

This principle would make sense only in a language in which you could
dynamically create subclasses of a dynamically chosen class at runtime.
In that case, it would be an instance of the Liskov substitution
principle.  C++ does not allow that sort of dynamic behaviour.

Even in a hypothetical language C+=42 that did allow such dynamic class
creation and runtime derivation, the principle would not always apply.
If you're using private inheritence, then that the fact that
`foo' "is-a" `bar' is private, and so classes derived from `foo'
should not be able to take advantage of that.

--
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]



