Sunday, 15 April 2012

Explain the concept of template. | C++

a Templates allow you to describe a generic type to manage other data types. Using templates, you can implement the algorithm once in your code and use it with many different types of data, even with objects. Templates are of two types—Class template (which is used to build general-purpose container classes, such as stacks, lists, and queues) and Function template (which is defined as a function using an abstract classes, non-specific data types and then use that as int or float).
The template specifier has the following two parameter types:

? template <class identifiers function_declaration
? template <typename identifier> function_declaration

No comments: