C++ Templates

Author

Clayton Cafiero

Published

2025-01-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

Copyright © 2023–2025 Clayton Cafiero

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