Exploring template basics to genericize code
Templates allow code to be generically specified in a manner that is abstracted from the data types primarily used within relevant functions or classes. The motivation for creating templates is to generically specify the definition of functions and classes that we repeatedly want to utilize, but with varying data types. The individualized versions of these components would otherwise differ only in the core data type utilized; these key data types can then be extracted and written generically.
When we then opt to utilize such a class or function with a specific type, rather than copying and pasting existing code from a similar class or function (with preset data types) and changing it slightly, the preprocessor instead would take the template code and expand it for our requested, bonafide type. This template expansion capability allows the programmer to write and maintain only one version of the genericized code, versus the many type...