Day 19. Templates

A powerful tool for C++ programmers is “parameterized types” or templates. Templates are so useful that a library containing a number of routines using templates has been adopted into the definition of the C++ language.

Today, you will learn

• What a template is and how templates can be used

• How to create class templates

• How to create function templates

• What the Standard Template Library (STL) is and how to use some of the templates within it

What Are Templates?

At the end of Week 2, you saw how to build a PartsList object and how to use it to create a PartsCatalog. If you want to build on the PartsList object to make a list of cats, you have a problem: PartsList only knows about parts.

To solve this problem, you can ...

Get Sams Teach Yourself C++ in 21 Days , Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.