I'm new to C++, but it seems to me that template functions and function overloadingHTML Code:templates Vs function overloading
is, sort of, the same. Am I right, or have I missed something?
Printable View
I'm new to C++, but it seems to me that template functions and function overloadingHTML Code:templates Vs function overloading
is, sort of, the same. Am I right, or have I missed something?
They have some similarities. The key difference is that with templates you write one implementation, which is the same for all types, but with function overloading you write separate implementations that can be different.Quote:
Originally Posted by adapanaidu
I hape that can get you started.
thanks Andrew.
regards,
adapa.
You will find this interesting = http://www.gotw.ca/gotw/049.htm
Also, the differences that exist between a function template and explicitly written overload do also hold.
Also, with function templates - the function being called is implicitly generated based on an exact match (even when a very close match specialization or overload is provided). While with function overloading - if you don't provide an exact match - the closest match one is called. The above article will expand on this thought.