473,399 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Jumps through a program

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
Jul 22 '05 #1
3 1637
Jeffrey Baker wrote:
Technically, which is more efficient, to jump to the 100th function of
one class or to jump to the 100th class?


What do you mean by "jump to the 100th function" or jumping to a class?
Jul 22 '05 #2
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.

--
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

Jul 22 '05 #3

"Thomas Matthews" <Th**********************@sbcglobal.net> wrote in message
news:hD******************@newssvr31.news.prodigy.c om...
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

Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jashan | last post by:
Hi All I have a table in SQL Server with ID having indentity inrement by one. Table has not any trigger. Frequently ID in the table jumps. Any help !!! Thanks
0
by: Cathy | last post by:
Hi, Has anyone else experienced this problem while working in the VB.Net code behind: when selecting text with the mouse, the text does not stay selected but instead the selection jumps to...
0
by: misscrf | last post by:
I have an entry form which has a tab control. If print screens are needed, please let me know and I will prepare them and post them. Anyway, this tab control has 3 pages. When I am on one of the...
3
by: ken | last post by:
I have a subform with records that contain check boxes. This subform is a continuous form. When you check a checkbox on a record in the bottom part of the form(you have to scroll to go down there)...
3
by: John Knoop | last post by:
Hi Suppose this page is currently loaded: http://localhost/myapp/?page=news Default.aspx in the Myapp folder will then include /news/default.aspx. In the file /news/default.aspx there is a...
11
by: David Schwartz | last post by:
When I run my VB.NET Windows Forms application, the CPU usage jumps up to 100%. If I drop-down a menu, the usage goes down to a more reasonable number, like 0-2%. The same is true when a MsgBox...
0
by: VMI | last post by:
I have a user control with a radioButtonList, and when I change the value, it automatically jumps to the top of the page. They do AutoPostBack, so that could be the reason, but is it possible that...
0
by: VMI | last post by:
I have a user control with a radioButtonList, and when I change the value, it automatically jumps to the top of the page. The radioButtonList does an AutoPostBack, so that could be the reason, but...
26
kcdoell
by: kcdoell | last post by:
Hello: I have a continuous form that displays records. In the AfterUpdate event of one of the fields, Binding_Percentage, I have the following code: Private Sub...
4
by: olseni | last post by:
Hi all I have a problem using datasheet in a subform (Access 2007). When the user is updating numbers or text in a column, and jumps to the next record using the 'Enter' button, sometimes, but...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.