C++ Tutorial on Templates

After all the knowledge about generic programming using C++ class template, the next one to know will be about some sort of specifics called C++ Class Template Specialization. There is an exception to every rule. Any generic code development will need a small case where it needs to do some hard coding or to avoid [...]

C++ Class Templates are used where we have multiple copies of code for different data types with the same logic. If a set of functions or classes have the same functionality for different data types, they becomes good candidates for being written as Templates. One good area where this C++ Class Templates are suited can [...]

Function templates in C++ are used if the same set of code/algorithm needs to be applied for different data types. The same logic need not be repeatedly written for different data types, involving lots of manual effort in development, testing, debugging and fixing. Instead C++ compiler itself takes the burden and produces different signatures for [...]

   C++ Function templates are those functions which can handle different data types without separate code for each of them. For a similar operation on several kinds of data types, a programmer need not write different versions by overloading a function. It is enough if he writes a C++ template based function. This will take [...]