The Pros and Cons of Templates

Discover the advantages and disadvantages of using templates.

Before we start using templates, it’s important to understand the benefits of using them as well as the disadvantages they may incur.

Advantages of templates

Let’s start by pointing out the advantages:

  • Templates help us avoid writing repetitive code.

  • Templates foster the creation of generic libraries providing algorithms and types, such as the standard C++ library (sometimes incorrectly referred to as the STL), which can be used in many applications, regardless of their type.

Get hands-on with 1200+ tech skills courses.