From -7969063946549420597
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,8c9f1307b83ac2db
X-Google-Attributes: gidf78e5,public
From: Valentin Bonnard <bonnardv@pratique.fr>
Subject: Re: Q: virtual functions not overridable anymore?
Date: 1997/09/26
Message-ID: <34293558.73F@pratique.fr>#1/1
X-Deja-AN: 275854261
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> <341E7C8E.EA4@pratique.fr> <3420858D.12DB@mWilden.com>
X-Original-Date: Wed, 24 Sep 1997 17:44:25 +0200
Organization: Internet Way
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBNCw5U0y4NqrwXLNJAQGeQAIAjDVnH76baMczoNVdbO9VAzvlLfT739di unBy7FSiRvCYFBkVZauntEaeriMm891E0qGNSwpMfyv7gtz9LoF1ZQ== =x4kz
Reply-To: bonnardv@pratique.fr
Newsgroups: comp.std.c++
Originator: austern@isolde.mti.sgi.com


Mark Wilden <Mark@mWilden.com> writes:

> Valentin Bonnard wrote:
> > 
> > Let's say you have the following GUI classes:
> > 
> > class Window {
> >     virtual void draw () = 0;
> > };
> > 
> > class Dialog {
> >     void draw ()
> >     {
> >         for_each (items.begin (), items.end (),
> >                   ptr_mem_fun (DialogItem::draw));
> >     }
> >     list<DialogItem> items;
> > };

[...]

> > You might want to declare Dialog::draw () final as at this point,
> > behaviour should be changed by deriving from DialogItem, not Dialog.
> 
> That would prevent you from doing something like this:
> 
>  struct DebugDialog : Dialog {
>     void draw()
>     {
>         cout << "About to draw dialog" << endl;
>         Dialog::draw();
>         cout << "Done drawing dialog" << endl;
>     }
>  };

But any non-virtual function prevents you from doing that.

virtual functions aren't a way to patch program to remove 
bugs or to introduce debugging tests; they are a way to 
write OO programs where the derived class define a function
the correct way.

Your argument is against non-virtual functions (thus all 
non-members functions), not against final.

Remember: the original argument was: since we have 
non-virtual functions, we should have final functions 
(ie non-virtual functions overiding from virtual 
functions).

-- 

Valentin Bonnard                mailto:bonnardv@pratique.fr
info about C++/a propos du C++: http://www.pratique.fr/~bonnardv/
---
[ 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 
]



