How do we start learning about C++ templates?

Learning about C++ templates

When starting with C++, learn about the following templates programming topics:

  • Basic function template declaration
  • Basic class template declaration
  • Template specialization

The right amount of template introduction

Generic programming using templates in C++ is a complex topic. In the beginning, only a brief introduction to C++ template programming is advised. It can be helpful because:

  • The entire C++ Standard Library is implemented through templates
  • We can better understand how to deal with verbose, template-related compilation errors

When starting with C++, do not spend too much time learning about templates, because, in the beginning, we need to learn about C++ and the C++ Standard Library basics first. Templates are a complex topic and can be seen as a language within a language. That is why only a brief, basic template introduction is advised initially.

Posted on January 15, 2025, by

Slobodan Dmitrovic

Slobodan Dmitrovic is a software development consultant, C++ trainer, and author of several books on C and C++.

Contact Slobodan for C++ training and consultancy services.