What is template ? And how to make template class | Sololearn: Learn to code for FREE!

+4

What is template ? And how to make template class

c++

10/27/2016 7:16:11 PM

mirza arslan

1 Answer

New Answer

+2

A template is an abstract description of a function or a class that requires one or multiple compile time parameter(s) in order to form a complete function or class. The parameters are usually a type or an integer. Minimum example for a template class: template<typename T> class A {}; Note: class template As template parameter T is unused in the definition of the class. Usually one would use it of course. Far more complex examples for class templates are the containers in the standard library (e.g. vector, list etc.) The template parameter T must be filled in to form a complete class from the class template A: A<float> a1; A<78> a2;