K
kelvSYC
In C, can you make functions like this:
int foo(int a);
int foo(int a, char b);
....
etc.
int foo(int a);
int foo(int a, char b);
....
etc.
kelvSYC said:In C, can you make functions like this:
int foo(int a);
int foo(int a, char b);
In C, can you make functions like this:
int foo(int a);
int foo(int a, char b);
...
etc.
Ben Pfaff said:
Sadly not! ......
It has it's own advantages and disadvantages. C code turns out to make
smaller and more efficient executables when compared with C++, right?
if so, then it's not because C lacks overloading of function names.
[email protected] said:I think overloading of functions *does* take up some extra
memory when compared to using 2 functions with different names.
I think overloading of functions *does* take up some extra memory when
compared
to using 2 functions with different names.
IMO you think wrong. A C++ function overload *is*
a function with a different name. C++ simply
'hides' this fact.
load the function into memory only when required.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 >
C++ allows thisBTW do the latest C compilers use dynamic binding?
[email protected] said: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?
No.
Ben Pfaff said:Would you please cut it out with the 20-plus blank lines at the
end of every article?
Would you please cut it out with the 20-plus blank lines at the
end of every article?
[email protected] said:Yes, but in doing so it takes up some extra steps which in turn results in
comparatively slower execution and more memory.
Nonsense.
Any extra steps/slower execution happens in the
*compiling* phase, not affecting the actual execution of your
particular application (I have yet to hear of a conforming C++
interpreter...), and will still happen much quicker than the
time it takes you to write out two distinct function names.
[email protected] said:(snip)
I've heard that a "hello" world program on C++ takes up more space when
compared with C.
Is that wrong?![]()
[email protected] said:Why don't you object those who use OE and break quotes instead?
One rude or incorrect behavior does not justify another.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.