This guide will help you and provide a detail information of templates in C ++

Introduction

Templates are a feature of the C++ programming language that allows functions and classes to be generic. This allows a function or class to work on many different data types without being rewritten for each one. Thus it helps the programmers when combined with multiple inheritance and operator overloading.

Advantages

This is called a symbol that either a function, structure or a class. The interest lies in its templates:

  • Generous: as long as the type parameter provides everything that is used in the symbol template, you can pass any kind
  • Simplicity: it is a symbol code whatever data type is passed as a parameter, making the code much easier to maintain

Disadvantages

  • As we shall see subsequently the use of template requires some precautions (type name...)
  • The program takes longer to compile.