Skip to main content

Templates

http://www.geeksforgeeks.org/templates-cpp

Template is simple and yet very powerful tool in C++. The simple idea is to pass data type as a parameter so that we don't need to write same code for different data types.

C++ adds two new keywords to support templates:'template'and'typename'. The second keyword can always be replaced by keyword 'class'.

Both function overloading and templates are examples of polymorphism feature of OOP

Function overloading is used when multiple functions do similar operations, templates are used when multiple functions do identical operations.

Template specialization allows us to have different code for a particular data type.

Template MetaProgramming in C++

http://www.geeksforgeeks.org/template-metaprogramming-in-c