Jeffrey said:
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.