Newsgroups: comp.lang.c++,comp.lang.smalltalk,comp.lang.eiffel,comp.lang.ada,comp.object,comp.software-eng
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!portc01.blue.aol.com!newsxfer3.itd.umich.edu!news.bbnplanet.com!su-news-hub1.bbnplanet.com!news.sprintlink.net!news-peer.sprintlink.net!howland.erols.net!vixen.cso.uiuc.edu!uwm.edu!rutgers!utcsri!info.ecf!doylep
From: doylep@ecf.toronto.edu (Patrick Doyle)
Subject: Re: What is wrong with OO ?
Sender: news@ecf.toronto.edu (News Administrator)
Message-ID: <E448IK.4qI@ecf.toronto.edu>
Date: Thu, 16 Jan 1997 19:23:08 GMT
X-Nntp-Posting-Host: spark27.ecf
References: <JSA.97Jan1181506@alexandria> <01bbd23a$5b667cc0$LocalHost@christophe-leph> <E440xD.Lu0@ecf.toronto.edu> <01bc03db$2de477c0$ba1e1990@ap352pc.us.oracle.com>
Organization: University of Toronto, Engineering Computing Facility
Lines: 42
Xref: glinda.oz.cs.cmu.edu comp.lang.c++:240840 comp.lang.smalltalk:49238 comp.lang.eiffel:17392 comp.lang.ada:56057 comp.object:59900 comp.software-eng:52601

In article <01bc03db$2de477c0$ba1e1990@ap352pc.us.oracle.com>,
Risto Lankinen <rlankine@us.oracle.com> wrote:
>
>Patrick Doyle <doylep@ecf.toronto.edu> wrote in article
><E440xD.Lu0@ecf.toronto.edu>...
>> 
>>   Suppose a function does some important manipulation of private data
>> members.  If it were virtual, then an heir class could override this
>> function without ever calling it, and the data manipulation would never
>> happen.  This could leave the object in an invalid state.  In C++, the
>> only way to prevent this is by NOT declaring the function virtual.
>
>This is true.  I would like to add, that if *both* the important data
>manipulation *and* virtualness are needed, then there is still a way
>to do it.  Here's how:
>
>--------------------------------------------------
>class Base
>{
>private:
>   virtual void Function_imp()

  I was not aware that private virtual functions existed.  Can a descendant
class override this function even though it does not have access to it?

>Note that *IF* the Java keyword 'final' was also in C++ (in Java
>it means that a member function cannot be overridden, or a class
>cannot be derived) then in the example, 'Base::Function()' could
>itself be a virtual function derived from yet-another-base, but
>then overridden and declared as 'final'.  Obviously this would
>make it possible to stack postcondition checks by doing the same
>'final'-trick to 'Derived::Function_imp()' and have it call, say,
>private virtual 'Function_imp_imp()' that *its* derived classes
>can override...

  Woah, sorry, you lost me here.  Do you have an example of what you're
thinking of?

-- 
--
Patrick Doyle
doylep@ecf.utoronto.ca
