|
-
June 2nd, 2006, 06:55 AM
#1
templates Vs function overloading
HTML Code:
templates Vs function overloading
I'm new to C++, but it seems to me that template functions and function overloading
is, sort of, the same. Am I right, or have I missed something?
-
June 2nd, 2006, 07:36 AM
#2
Re: templates Vs function overloading
 Originally Posted by adapanaidu
HTML Code:
templates Vs function overloading
I'm new to C++, but it seems to me that template functions and 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.
I hape that can get you started.
-
June 5th, 2006, 11:52 PM
#3
Re: templates Vs function overloading
thanks Andrew.
regards,
adapa.
-
June 6th, 2006, 05:15 AM
#4
Re: templates Vs function overloading
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.
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|