Templates let you write a single function or class that works with any data type — like C# generics or TypeScript templates.
template <typename T> before your function or class to create a template for any type. You can also use template <class T> — it works the same.
template <typename T> — declares a template for type TT add(T a, T b) — function works with whatever type you passadd(2, 3) — works with intsadd(2.5, 3.5) — works with doublesadd(string, string) — works with strings too