Share this post

Link to post

Share on other sites

Templates are C++'s method to parameterized code at compile time, generally through the use of type parameters. The basic gist is I can define a class or function that I might want to use with different types and only want to write once. In that case I can template that code based on that type. For example, the swap function for integers looks like: