FUNCTION OF GENERIC
Templates are the foundation of generic programming,
which involves writing code in a way that is independent
of any particular type.
A template is a blueprint or formula for creating a generic
class or a function. The library containers like iterators
and algorithms are examples of generic programming and have
been developed using template concept.
There is a single definition of each container, such as vector,
but we can define many different kinds of vectors for example,
vector <int> or vector <string>.
You can use templates to define functions as well as classes,
let us see how they work:
No comments:
Post a Comment