From -2271836984141724303
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,8c9f1307b83ac2db
X-Google-Attributes: gidf78e5,public
From: Mark Wilden <Mark@mWilden.com>
Subject: Re: Q: virtual functions not overridable anymore?
Date: 1997/09/18
Message-ID: <3420858D.12DB@mWilden.com>#1/1
X-Deja-AN: 273711007
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>
X-Original-Date: Wed, 17 Sep 1997 18:36:13 -0700
Organization: The Mark Wilden Company
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBNCHdfUy4NqrwXLNJAQEE7AH8CJp14/HKMrHutOIQ3sjxMd0+SpMjlIGd QtQXw06et4B4bJtkNmN01Yj5fH1kHS/Y0QzDAhzeywQvnW9tv8sOMw== =8yl3
Newsgroups: comp.std.c++
Originator: austern@isolde.mti.sgi.com


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;
> };
> 
> class DialogItem {
>     virtual void draw () = 0;
> };
> 
> 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;
    }
 };
---
[ 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 
]



