The C++Course provides a general introduction to programming in C++. It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details.


Now that you have a decent amount of experiencing coding, allow me to ask you a question. Have you noticed how many functions that perform the same tasks look similar? For example, if you wrote a function that prints an int, you would have to have the int declared first. This way, the possibility of error in your code is reduced, however, it gets somewhat annoying to have to create different versions of functions just to handle all the different data types you use. Oh wait...we've got templates.

Parameterized types, better known as templates, allow the programmer [you] to create one function that can handle many different types. Instead of having to take into account every data type, you have one arbitrary parameter name that the compiler then replaces with the different data types that you wish the function to use, manipulate, etc.

Last Update: 2005-12-05