Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #9819

Re: does virtualizing all methods slow C++ down ?

From Lynn McGuire <lmc@winsim.com>
Newsgroups comp.lang.c++
Subject Re: does virtualizing all methods slow C++ down ?
Date 2011-09-06 14:09 -0500
Organization A noiseless patient Spider
Message-ID <j45r7m$bod$1@dont-email.me> (permalink)
References <j45hvi$6at$1@dont-email.me> <c19c435c-8bf2-4e31-a950-72336682ca15@q8g2000yqe.googlegroups.com>

Show all headers | View raw


On 9/6/2011 12:00 PM, Christopher wrote:
> On Sep 6, 11:31 am, Lynn McGuire<l...@winsim.com>  wrote:
>> Does virtualizing all methods slow C++ down ?  We
>> virtualize all methods as a matter of course since
>> we use groups of objects all over the place.  To
>> illustrate this I have included the top portion of
>> our header files:
>>
>> class GenGroup : public DataGroup
>> {
>> public:
>>      int transferingDataNow;
>> public:
>>         //  constructor
>>      GenGroup ();
>>      GenGroup (const GenGroup&  rhs);
>>      GenGroup&  operator = (const GenGroup&  rhs);
>>         //  destructor
>>      virtual ~GenGroup ();
>>      virtual GenGroup * clone () { return new GenGroup ( * this); }
>>      virtual void makeUnitsInput (InputCollection * anInpCol);
>>      virtual void reinitStreamBox (FmFile * FMFile);
>>      virtual DataDescriptor * descriptor (int aSymbol, int version);
>> ...
>>
>> Thanks
>> Lynn
>
> If you virtualize one, there is no cost for virtualizing the others.
> There is a cost associated with virtualizing one method. See the FAQ.
>
> I wouldn't virtualize every single method in every single class
> though. That is just not thoughtful design. When I see a virtual
> method, I assume the author INTENDED for the class to be derived from.
> Surely, you have a concrete class somewhere.

We have so many methods in our 600 classes and 700K lines
of code that we are not sure what needs to be virtual and
does not.  So we do all to keep from missing 1, 2 or 20.

Thanks,
Lynn

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

does virtualizing all methods slow C++ down ? Lynn McGuire <lmc@winsim.com> - 2011-09-06 11:31 -0500
  Re: does virtualizing all methods slow C++ down ? Christopher <cpisz@austin.rr.com> - 2011-09-06 10:00 -0700
    Re: does virtualizing all methods slow C++ down ? Lynn McGuire <lmc@winsim.com> - 2011-09-06 14:09 -0500
      Re: does virtualizing all methods slow C++ down ? Christopher <cpisz@austin.rr.com> - 2011-09-06 12:35 -0700
        Re: does virtualizing all methods slow C++ down ? "Kevin P. Fleming" <news@kpfleming.us> - 2011-09-06 16:41 -0500
      Re: does virtualizing all methods slow C++ down ? "Balog Pal" <pasa@lib.hu> - 2011-09-11 12:02 +0200
    Re: does virtualizing all methods slow C++ down ? "Thomas J. Gritzan" <phygon_antispam@gmx.de> - 2011-09-07 02:42 +0200
      Re: does virtualizing all methods slow C++ down ? Noah Roberts <roberts.noah@gmail.com> - 2011-09-07 07:39 -0700
        Re: does virtualizing all methods slow C++ down ? Richard Damon <news.x.richarddamon@xoxy.net> - 2011-09-07 11:46 -0400
    Re: does virtualizing all methods slow C++ down ? Nobody <nobody@nowhere.com> - 2011-09-07 01:45 +0100
  Re: does virtualizing all methods slow C++ down ? Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2011-09-06 19:12 +0200
    Re: does virtualizing all methods slow C++ down ? Lynn McGuire <lmc@winsim.com> - 2011-09-06 14:13 -0500
      Re: does virtualizing all methods slow C++ down ? jacob navia <jacob@spamsink.net> - 2011-09-06 21:57 +0200
        Re: does virtualizing all methods slow C++ down ? Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2011-09-06 22:40 +0200
          Re: does virtualizing all methods slow C++ down ? Lynn McGuire <lmc@winsim.com> - 2011-09-06 16:13 -0500
            Re: does virtualizing all methods slow C++ down ? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-09-07 08:01 +0000
              Re: does virtualizing all methods slow C++ down ? Lynn McGuire <lmc@winsim.com> - 2011-09-14 12:08 -0500
                Re: does virtualizing all methods slow C++ down ? Lynn McGuire <lmc@winsim.com> - 2011-09-14 14:04 -0500
        Re: does virtualizing all methods slow C++ down ? Lynn McGuire <lmc@winsim.com> - 2011-09-06 16:11 -0500
          Re: does virtualizing all methods slow C++ down ? Paavo Helde <myfirstname@osa.pri.ee> - 2011-09-07 11:44 -0500
            Re: does virtualizing all methods slow C++ down ? Joshua Maurice <joshuamaurice@gmail.com> - 2011-09-07 14:11 -0700
              Re: does virtualizing all methods slow C++ down ? Paavo Helde <myfirstname@osa.pri.ee> - 2011-09-08 01:26 -0500
              Re: does virtualizing all methods slow C++ down ? Nobody <nobody@nowhere.com> - 2011-09-08 07:37 +0100
              Re: does virtualizing all methods slow C++ down ? zindorsky <nephi.allred@gmail.com> - 2011-09-09 10:20 -0700
                Re: does virtualizing all methods slow C++ down ? "Kevin P. Fleming" <news@kpfleming.us> - 2011-09-10 11:48 -0400
                Re: does virtualizing all methods slow C++ down ? Nobody <nobody@nowhere.com> - 2011-09-10 17:58 +0100
  Re: does virtualizing all methods slow C++ down ? Juha Nieminen <nospam@thanks.invalid> - 2011-09-07 06:19 +0000
  Re: does virtualizing all methods slow C++ down ? Goran <goran.pusic@gmail.com> - 2011-09-06 23:52 -0700
    Re: does virtualizing all methods slow C++ down ? Juha Nieminen <nospam@thanks.invalid> - 2011-09-07 07:57 +0000
      Re: does virtualizing all methods slow C++ down ? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-09-07 10:39 +0000
      Re: does virtualizing all methods slow C++ down ? Goran <goran.pusic@gmail.com> - 2011-09-07 04:30 -0700
        Re: does virtualizing all methods slow C++ down ? Juha Nieminen <nospam@thanks.invalid> - 2011-09-07 13:04 +0000
          Re: does virtualizing all methods slow C++ down ? Goran <goran.pusic@gmail.com> - 2011-09-07 06:18 -0700
  Re: does virtualizing all methods slow C++ down ? ld <laurent.deniau@gmail.com> - 2011-09-08 05:34 -0700

csiph-web