From C to C++ - templates
January 28, 2025, by Slobodan Dmitrovic
When moving from C to C++, templates are one of the biggest novelties we encounter.
Generic programming using templates
Templates allow for generic programming - programming for any type. Templates are mainly used to create:
- Function templates
- Class templates
What should we learn about templates?
We should learn about the following topics first:
- Basic function template declaration
- Basic class template declaration
- Template specialization
The entire C++ Standard Library is implemented through templates, and this enables us to have robust containers and algorithms that can hold/operate on almost any data type.
If a template is not instantiated, it does not get compiled into a binary file.
Template meta-programming in C++ is widely used in general software development and embedded systems programming.

We also have a dedicated training course called "C++ for C Developers." For more info, contact us at contact@cppsrc.com.
Download the Brochure