C++ Templates

Published

2023-08-05

With C++ templates you can create classes or functions that deal with multiple data types almost automatically. You define the template and instantiate a class or call a function specifying the appropriate data type, and the C++ compiler will generate the code for each data type! How cool is that?

We’ll be using templates throughout the course, starting with the upcoming node class for singly-linked lists. Accordingly, it’s important that you have a good grasp of how templates are used in C++. This video (7:09) provides an introduction. There’s an additional tutorial and FAQ referenced below.

Resources

Supplemental reading

Original author: Clayton Cafiero < [given name] DOT [surname] AT uvm DOT edu >

No generative AI was used in producing this material. This was written the old-fashioned way.

All materials copyright © 2020–2023, The University of Vermont. All rights reserved.