I know that this question might not be related to codechef but still… What is a c++ template ? I searched the net and found results but they were far beyond my comprehension. If you can, please give examples of its use and its working along with the explanation. I’m a newbie and thus if you can please explain in a manner I can actually understand ( I’m not very smart either ) . I’m not too experienced with c++11 but am a novice in the previous versions ( Borland c++ ) . Any info would be really appreciated.
Start Reading the standard books, like “The C++ Programming Language by Bjarne Stroustrup”. You will get to know a lot of new stuff.
Basically you can say that if we keep classes or whether you can say that OOP’s some functionalities (Object Oriented Programming) at other hand than in simple words
STL is the main thing which identifies the C++ and keeps it one step ahead of from C language
STL --> It’s full form is Standard Template Library and all the templates what we use that we put in this category
Now basic thing to learn about templates is that like if you have a array of having some numbers and you want to sort that in minimum time so you will go with Merge Sort but if you do not want to write extra code for sorting than for that case you can easily use one of the template called “algorithm.h” , and through this you will just have to write sort(range of array)a nd it will successfully sort that for the given range.
We have one more example is that for some case if you need any array having dynamic size so that for that you can use directly “vector.h” and with the help if this you can easily create a dynamic array
some template libraries are—
and many more
but if you want to include all this in one header file than for that case you can use
hope that helped you.