The difference between functions and templates?

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2003
Posts: 2
Reputation: Nasimov is an unknown quantity at this point 
Solved Threads: 0
Nasimov Nasimov is offline Offline
Newbie Poster

The difference between functions and templates?

 
0
  #1
Dec 4th, 2003
What is the difference between function template & template function?

Thanks.
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,053
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 130
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Re: The difference?

 
0
  #2
Dec 4th, 2003
Well, you could have a regular ol' function named template. i.e. int template(char letter) or void template() or any other combination you could have for a function. There's also a C++ thingie called templates, where you would do something such as Template<T> or something along those lines. (I've never learned/used them personally). However, what they allow you to do is abstract data types out from your code. For example, take the algorithm for a linked list. You can add data to the list, remove data, search the list, sort the list, etc. However, just to add data to the end of the list, for example, it doesn't matter what data type the list is. Templates allow you to avoid redoing multiple classes and functions for an integer linked list, a character linked list, a double linked list, etc. Rather, you can abstract out this data by creating a linked list of type T. This way you can reuse that part of your code.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC