Article View: comp.std.c++
Article #2347Re: Why allow virtual function calls in constr
From: David Vandevoorde
Date: Mon, 30 Oct 1995 03:06
Date: Mon, 30 Oct 1995 03:06
40 lines
2650 bytes
2650 bytes
>>>>> "SC" == Steve Clamage <clamage@Eng.Sun.COM> writes: [...] SC> But how do you know, given a set of library classes supplied in binary SC> form, what virtual functions are called from which constructors and SC> destructors? When I write a class, how do I know what classes will SC> someday be derived from it, and what future virtual functions might be SC> safe to call from my class's constructors and destructor? True, but that is always the case with virtual functions. If you don't want overriding outside your control, there are other options for that (e.g., a virtual call to a private hierarchy of helper classes). If you don't want overriding at all; you can always fully qualify the call. SC> Suppose the class library I acquire describes the virtual functions SC> called from each ctor/dtor. I make a check list to be sure that SC> any overriding virtual functions are safe to call from the base SC> class. Someone else now derives from my class, and has to combine SC> the data from all the base classes to figure out which new SC> overrides might be called from some base class ctor/dtor. [...] It would probably be a poorly designed library. Most reasonable techniques I can imagine with virtual calls from a constructor would be that the call resolves to the full object which is then reponsible to relay-call the same function its base components. What was the argumentation that lead to give defined semantics to calls to virtual functions in constructors? [...] SC> I think you would have to add this feature, or else disallow SC> virtual calls from constructors and destructors. Right now, I think it makes sense disallowing them. Daveed --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<VANDEVOD.95Oct29144834@avs.cs.rpi.edu>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backReferences:
<46kuqc$j45@manuel.anu.edu.au> <46mgqo$e5b@engnews2.Eng.Sun.COM> <9530301.15557@mulga.cs.mu.OZ.AU> <470gvp$i3h@engnews1.eng.sun.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back Date: 30 Oct 95 03:06:53 GMT Approved: fjh@cs.mu.oz.au From: vandevod@cs.rpi.edu (David Vandevoorde) Newsgroups: comp.std.c++ Subject: Re: Why allow virtual function calls in constr X-Original-Date: 29 Oct 1995 19:48:34 GMT Organization: RPI Computer Science Message-ID: <VANDEVOD.95Oct29144834@avs.cs.rpi.edu> References: <46kuqc$j45@manuel.anu.edu.au> <46mgqo$e5b@engnews2.Eng.Sun.COM> <9530301.15557@mulga.cs.mu.OZ.AU> <470gvp$i3h@engnews1.eng.sun.com> In-Reply-To: clamage@Eng.Sun.COM's message of 29 Oct 1995 19:55:44 GMT X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMJRBXeEDnX0m9pzZAQFPbgF/QOVTpkAQ9tts+9T0IzLkNXMNzB5MF/HG Yo6sKiriTFNyRgsIWLbyLkekIRYB9NRk =Iz02