CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2006
    Location
    Inida
    Posts
    119

    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?

  2. #2
    Join Date
    Apr 1999
    Posts
    50

    Re: templates Vs function overloading

    Quote 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.

  3. #3
    Join Date
    Mar 2006
    Location
    Inida
    Posts
    119

    Re: templates Vs function overloading

    thanks Andrew.


    regards,
    adapa.

  4. #4
    Join Date
    Feb 2005
    Location
    "The Capital"
    Posts
    5,306

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured