<no@no.invalid> wrote in message
IMO you think wrong. A C++ function overload *is*
a function with a different name. C++ simply
'hides' this fact.
Yes, but in doing so it takes up some extra steps which in turn results in
comparatively slower execution and more memory. Overloaded
function resolution is not as simple as the programmer himself naming
the functions differently.
It compensates this by features such as dynamic binding and hence may >
load the function into memory only when required.
BTW do the latest C compilers use dynamic binding?
C++ allows this
double root(double x);
double root(Quaternion q);
so you can take the root of a real or a quaternion using natural function
names. The C++ compiler will implement this by producing two functions with
mangled names, eg root_d and root_Quaternion. There is no runtime penalty
compared with writning two C functions with slightly different names.
However C++ also allows this
class number
{
public:
virtual void root(void) = 0;
};
Now we can declare "real" and "quaternion" as objects of type "number", and
provide for each a routine to reduce them to a square root.
The program decides what type "number" is a run time, and accesses the
function "root" through a pointer. There is therefore a speed and time
penalty compared with providing two directly-called C functions, though of
course the ability to use object-oriented design arguably compensates for
this.
Some platforms also put commonly-used library functions in separate modules
from the main executable. The OS may provide some sort of intelligent
management by only loading those functions which are needed at the time.
This has nothing to do with run-time binding in the C++ sense.
To answer the last question, you would have to clarify in what sense you are
using the term "dynamic binding".