Re: Jumps through a program
From: Jeffrey Baker (x1x1_at_tmove.com)
Date: 11/19/03
- Next message: Victor Bazarov: "Re: multiple word error"
- Previous message: Giovanni Noppe: "multiple word error"
- In reply to: Thomas Matthews: "Re: Jumps through a program"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 19 Nov 2003 16:40:25 GMT
"Thomas Matthews" <Thomas_MatthewsHatesSpam@sbcglobal.net> wrote in message
news:hDMub.31148$_n7.3883@newssvr31.news.prodigy.com...
> Jeffrey Baker wrote:
>
> > Technically, which is more efficient, to jump to the 100th function of
one
> > class or to jump to the 100th class? Class would be through inheritance
as
> > an object. Is there a comment on embeded objects to this subject too?
> >
> > Regards,
> > Jeffrey Baker
>
> If a class has 100 methods (member functions), executing any one of them
> is of order O(1) (unless they are virtual). The compiler will know the
> location of the function and supply code to call the function. Check
> your assembly code.
>
> If you have 100 individual classes then use a method from one of the
> classes (i.e. class_99.method()) this would be of order O(1). Again,
> the compiler will know the location of the function and insert the
> appropriate calling code.
>
> Some concepts that may add another layer of indirection:
> 1. inheritance
> 2. virtual methods
> 3. pointers to methods or functions.
>
> Inheritance may add another layer of indirection if the compiler
> must supply run-time code to find the function. Otherwise, the
> function is at a known location and the order is O(1).
>
> Virtual methods require some kind of run-time evaluation to
> find the correct method to execute. Some compilers speed up
> the process by using a table, although that isn't required.
>
> Pointers to methods or functions require that the compiler
> issue code to dereference the pointer before executing
> the function. This is a minimum of 1 level of indirection.
>
> I don't understand what your definition of "embeded objects"[sic]
> is. I work on embedded systems and my understanding may be
> different than yours. Please clarify.
Actually I don't know what I meant. I think I was thinking in terms of
another language in terms of basic way back when. I actually answered my
question after my sent post. Been away from C++ for a while. Thanks for
waking me up.
-- It is better to post code then to never tried. Jeffrey Baker > > -- > Thomas Matthews > > C++ newsgroup welcome message: > http://www.slack.net/~shiva/welcome.txt > C++ Faq: http://www.parashift.com/c++-faq-lite > C Faq: http://www.eskimo.com/~scs/c-faq/top.html > alt.comp.lang.learn.c-c++ faq: > http://www.raos.demon.uk/acllc-c++/faq.html > Other sites: > http://www.josuttis.com -- C++ STL Library book >
- Next message: Victor Bazarov: "Re: multiple word error"
- Previous message: Giovanni Noppe: "multiple word error"
- In reply to: Thomas Matthews: "Re: Jumps through a program"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|