| | |
The difference between functions and templates?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
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.
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

Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds
![]() |
Similar Threads
- Difference b/w stored proc and functions (MS SQL)
- expected init-declarator (C++)
- detecting '\n' without using getline (C++)
- Speed of member profiles (DaniWeb Community Feedback)
- forum n00b... (Community Introductions)
- Javascript Problem with Firefox (JavaScript / DHTML / AJAX)
- I dont see any difference between these 2 functions, DO YOU? (C)
Other Threads in the C++ Forum
- Previous Thread: compiling problems
- Next Thread: Completely new to C++ and have question about using char
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamic dynamiccharacterarray encryption error file format forms fstream function functions game givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib library linkedlist linker list loop looping loops map math matrix memory microsoft newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template templates test text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






