DAY 19
WEEK 3
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 PartsListobject and how to use
it to create a PartsCatalog. If you want to build on the PartsListobject to
make a list of cats, you have a problem:PartsListonly knows about parts.
To solve this problem, you can create a Listbase class. You could then cut and
paste much of the PartsListclass into the new CatsListdeclaration. Later,