Class Templates

In this lesson, we will learn about class templates in embedded programming.

A class template will be defined by placing the keyword template in front of the class template followed by type or non-type parameters.

  • The parameters are declared by class or typename.
  • The parameter can be used in the class body
  • You can define the methods of the class template inside or outside the class.
Press + to interact
template <typename T, int N>
class Array{
T elem[N];
...

Instantiation

The process of substituting the template parameter by the template arguments is called instantiation. In contrast to a ...

Access this course and 1400+ top-rated courses and projects.