From -7248009257687027039
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,c9300cc6a0b28243
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2003-08-12 11:40:49 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: andys@despammed.com (Andy Sawyer)
Newsgroups: comp.std.c++
Subject: Re: no_base_call
Date: Tue, 12 Aug 2003 18:40:48 +0000 (UTC)
Organization: International Rescue
Lines: 65
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <llu2txla.fsf@evo6.com>
References: <_azXa.385380$jp.11007710@twister.southeast.rr.com> <GtNYa.6$0q2.5739@news.ecrc.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: mail2news.demon.co.uk 1060713648 6101 10.0.0.1 (12 Aug 2003 18:40:48 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Tue, 12 Aug 2003 18:40:48 +0000 (UTC)
X-Received: from mulga.cs.mu.oz.au ([128.250.1.22])
	by news.demon.co.uk with esmtp (Exim 4.12)
	id 19me4d-0001aG-00
	for mail2news@news.news.demon.net; Tue, 12 Aug 2003 18:40:47 +0000
X-Received: from localhost (localhost [[UNIX: localhost]]) by mulga.cs.mu.OZ.AU
	id EAA27004; Wed, 13 Aug 2003 04:40:44 +1000 (EST)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Path: comp-std-cpp-robomod!not-for-mail
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Delivered-To: std-c++@ucar.edu
X-Newsgroups: comp.std.c++
X-DDate: Sweetmorn, Day 2 of the season of Bureaucracy, Anno Mung 3169
X-DoML: 14219
X-Attribution: AMS
X-URL: http://www.evo6.com
X-Face: 42Hn/fXjnx=kF5rNLj5)x7OM+-gqu*;\h"^gD}VRl+K;$lV<n=q++!+~(4U:A&U{If*>i/s
 G&,r!F_f>a[0&]+'}`%vo'"3d}U^Z5z`M(n2G5T(,,mQeJNx~tsLDO_BBpjH4?c~A`qi)*k7fq!W4|
 wZFKeB/=gY(kb0O=0!m?,`to)l;_Ux%<D]L<o\0>)L<nzAXV;*=GtaKf|C5Q"hsk\d)fm['C:"n[4o
 */L;0uY.R*1e=eOt78@Y
X-Cancel-Lock: sha1:ytN4AxSq4STEqbf6Q/folacAOHg=
X-User-Agent: Gnus v5.10.2/XEmacs
X-NNTP-Posting-Date: Sat, 09 Aug 2003 20:52:36 BST
X-Spam-Status: No, hits=-4.8 required=5.0
	tests=AWL,BAYES_01,REFERENCES,USER_AGENT
	version=2.55
X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp)
Xref: archiver1.google.com comp.std.c++:20583

In article <GtNYa.6$0q2.5739@news.ecrc.de>,
 on Fri, 8 Aug 2003 23:29:52 +0000 (UTC),
 deutronium@web.de ("cody") wrote:

> you can't create a virtual function and say what somebody has to do with is.
> this is the decision of the programmer.
>
> there are 3 things which you can do with a vitual function when overriding
> it:
>
> replace it:
> virtual void Func()
> {
> // your code goes here
> }
>
> extend it:
> virtual void Func()
> {
> Base::Func(); // call the base
> // your code goes here after the base call
> }
>
> intercept it:
> virtual void Func()
> {
> // your code before the basefunc is called
> Base::Func(); // call the base
> }

#pragma picky(on)
There's a fourth option - you can (if I may borrow your terminology)
both "intercept" AND "extend":
virtual void Func()
{
 // do stuff
 Base::Func(); 
 // do stuff
}
#pragma picky(off)

(In fact, you can also call the base function repeatedly if you really
want to, although I suspect that's rather uncommon)

> when you design a class you can never know what a programmer will do with
> your virtual functions in its derrived classes.

Unless you make them private, in which case you'll know that a
programmer can't call them directly, so he must either replace it or
leave it alone.

Regards,
 Andy S

-- 
"Light thinks it travels faster than anything but it is wrong. No matter
 how fast light travels it finds the darkness has always got there first,
 and is waiting for it."                  -- Terry Pratchett, Reaper Man

---
[ 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.jamesd.demon.co.uk/csc/faq.html                       ]



