Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.straub-nv.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Miles Bader Newsgroups: comp.lang.c++ Subject: Re: Virtual function call optimization Date: Tue, 27 Sep 2011 13:47:14 +0900 Organization: NEC Electronics Lines: 29 Message-ID: References: <55363b39-cfd1-4ec2-be5a-fa180c64c557@f6g2000vbm.googlegroups.com> <82c6cb18-21af-47c3-9d68-60cfc58121b6@k34g2000yqm.googlegroups.com> <4e80935c$0$31233$a8266bb1@newsreader.readnews.com> Mime-Version: 1.0 Content-Type: text/plain X-Trace: individual.net EREWDZV9vZMW1VUP8XAT9gIkfXfkt7Lk4P70pkurT3MotpDS0T Cancel-Lock: sha1:VMJEZ0anmuoOwXySGD/e9hnf3HU= sha1:3U1hOcx0ntpqTTyoH7eQjAd+F3I= System-Type: x86_64-unknown-linux-gnu Blat: Foop Xref: x330-a1.tempe.blueboxinc.net comp.lang.c++:10530 Richard Damon writes: > Another method, if you are willing to upgrade to C++11, and the object > definition allows it, is to declair foo() to be final, as in ... > class D: public B > { > public: > void foo() final ( ... } > } > > since D::foo is final, late binding is not needed if the pointer has > static type D. Or sometimes more conveniently, declaring the whole class D to be final: class D final : public B { public: void foo(); }; (which has the advantage that it will make all methods final, even those D doesn't override) -miles -- Accord, n. Harmony.