![]() |
|
#1
|
|||
|
|||
Class templatesHi Everyone
I am not able to understand the concept of the class templates can anyone help by sending some examples or any links which can easily understood Jaya Prakash Naveen |
|||
|
#2
|
|||
|
|||
Re: Class templatesAs far as links, google is your best bet.
The idea behind templates (in very short) can be illustrated by thinking about a sorting mechanism. Suppose that you have a class Auto that you provide an overloaded operator< for (that is given class Auto a1, a2 the following is a valid operation) CPP / C++ / C Code:
Here is where you can use some of the power of templates. Consider the following: CPP / C++ / C Code:
You may have noticed that I used the word set when describing how to store groups of the same object. This is another use of templates. In the stl (standard template library) you will find items such as vector, list, and map. These containers can hold any type of object and have a useful set of operations defined over them (insert, erase, push, pop, and iterators for traversing the sets - depending on what set you are using). Without the templates you would need to either define these operations for each type of set that there is or do some nasty void * casting. I hope that helps. |
|
#3
|
||||
|
||||
Re: Class templateshere's just a sample of what you can find using google:
http://http://www.iis.sinica.edu.tw/.../templates.htm http://www.codersource.net/cpp_class_templates.html http://www.cplusplus.com/doc/tutorial/templates.html there are litterally thousands more out there |
|
#4
|
|||
|
|||
Re: Class templatesTemplate is a concept where relate to Generic programming.
No matter what data type, the operation behind it is the same. __________________
Linux is the best OS in the world. |
|
#5
|
||||
|
||||
Re: Class templatesWhat's also great about templates is you can use them to create your own library that contains all the functions needed to work with an array, a struct, linked list, etc... instead of writing out those functions each time you need them in a program.
|
|
#6
|
|||
|
|||
Re: Class templateswww.cplusplus.com
may this link will help |
Recent GIDBlog
Updates On The All New Toyota VIOS - Part III by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Return pointer to template's nested class problem | Kimmo | CPP / C++ Forum | 2 | 20-Sep-2007 23:39 |
| Hard drive/CPU Diagnoses Issues | binarybug | Computer Hardware Forum | 1 | 22-Jan-2007 19:23 |
| Box Class, need help again :( | TransformedBG | CPP / C++ Forum | 7 | 13-Nov-2006 15:11 |
| a tester class and then some. | postage | Java Forum | 1 | 06-May-2006 15:48 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The