Templates are the foundation of generic programming, which involves writing code in a way that is independent of any particular type. Template class provides a specification for generating classes based on parameters. It generally used to implement containers. A template class is instantiated by passing a given set of types to it as template arguments.