It is a generic type. Something we relate to void * in C language.
It can take any type values. I mean ,It is easy to define a class like Vecror or List.But it is difficult to use the class with another type, we must replace all type names in the original file with the new type, this is a tedious and an error-prone process .
C++ provides a way to write a generic definition that works with any type --Here the answer is "templates". We use templates only to define classes that we want to work with many data types.
It can be used with classes or functions.
Boss it is also irritating if you are using GCC compiler.It's linker allways expect the template declaration and definition at a time while instatiating .If it does not see then there will be linking error some thing indefined error.
I had faced the same problem in STL some 4 years back. Actually In stl we can not have separate file for declaration and definion . It will have the linking problem.Because while instatiating , compile must see the declaration and definition at a time. . So while instatiating , by including mere .h will give the declarion , not the definition, so the linking problem.
In this case
Solution 1;
If we have 2 separate file i.e .h and .cpp , then while instatiting we should include .cpp instead of .h
Solution 2:we have to give the definition in .h itself, and while instatiting compiler does not face any problem because it see the both declaration and definition at a time.
Note:- the gcc has implemented the vector,list all thes predefined STL in this way ,if we open any of stl header file we can see these implemetation.
This linking proble generally we don’t face in Solarice, But is a ovious problem for gcc linker
Regards,
Haramohan sahu