Learn C++ in step-by-step lessons.
Templates
A template provides a way to write a function that will work with many different data types. Instead of writing one function to sort integers, another to sort strings, and another to sort double, we can write just one function using a template.
Goals:
- Be able to expain and use template functions
Objectives:
- Be able to write a template function to return minimum of any two values
- Write a sort to sort an array of any type
Please study the material at each of the links below.
- A Template function to return minimum of 2 values.
- A Template function to show 3 values
- A Template function to sort 3 values
- Using swap
- Finding a total
- A Template bubble sort
- A Template bubble sort with function prototype
Glossary for templates lesson
Full Glossary