1. Computing & Technology

Discuss in my forum

Definition of Template

By , About.com Guide

Definition: A template is a C++ feature that allows functions and classes to be defined with any type.

With a non-templated function, the parameters to that function are declared to be of a particular type. By defining a template function, that function can be called with a compatible type and the compiler will use the type derived from the parameter.

With template classes such as the Vector class in the STL, it is possible to create a vector class (an array that can change size at runtime) of say payroll objects. Because of the strict typing, only payroll obejcts can be stored in the list.

Glossary:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

©2012 About.com. All rights reserved.

A part of The New York Times Company.