From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7a180be12347b9d3 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,7a180be12347b9d3 X-Google-Attributes: gid1108a1,public X-Google-ArrivalTime: 2002-02-08 10:29:18 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news-x2.support.nl!newsgate.cistron.nl!news2.euro.net!uunet!ash.uu.net!spool0901.news.uu.net!spool0900.news.uu.net!reader0900.news.uu.net!not-for-mail From: "Hyman Rosen" Newsgroups: comp.lang.ada,comp.object References: <3c62524f.93369796@News.CIS.DFN.DE> <1013094178.985786@master.nyc.kbcfp.com> <3c6392e8.2400843@News.CIS.DFN.DE> Subject: Re: Merits of re-dispatching [LONG] Date: Fri, 8 Feb 2002 13:30:04 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Organization: KBC Financial Products Message-ID: <1013192956.289787@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@mosquito.nyc.kbcfp.com X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1013192954 reader0.ash.ops.us.uu.net 5645 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:19789 comp.object:33697 Date: 2002-02-08T13:30:04-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:3c6392e8.2400843@News.CIS.DFN.DE... > First C++ does not make any difference between class wide and specific > objects. The same type B is a class wide in B::f () and specific in > B::~B (). So the difference in how B::f and B::~B are dealing with > calls to g(). This is IMO bad. This is an incorrect view of what is happening. The type is class-wide in both B::f and B::~B. Calls to B::g are dispatching in both. It's just that while B::~B is running, the actual type of the object is B, so any dispatching happens according to B's virtual functions, even if the B part happened to be part of a derived class. Here's an example: struct A { virtual void foo() { cout << "A::foo\n"; }void call_foo() { foo(); } virtual ~A() { call_foo(); } }; struct B : A { void foo() { cout << "B::foo\n"; } ~B() { call_foo(); } } struct C : B { void foo() { cout << "C::foo\n"; } ~C() { call_foo(); } }; When a C object is destructed, it will print "C::foo"., "B::foo", "A::foo". > type is already *known*. Thus there is no need in [re-]dispatching. A > call to g() can be statically resolved. As in my example, not if the object is passed to some other routine which makes the dispatching call.