Standard Template Librar1

Standard Template Librar1 - numbers, strings, class...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Standard Template Library STL is a C++ library that has been voted by ANSI to be part of the C++ standard library. We normally think of software libraries as being sets of functions like printf() or malloc(). But the STL library is different. It's a collection of C++ templates, that is, parameterized types. For example, there is a template for manipulating lists, and you can have lists of ints or doubles or void*** pointers or class A objects. This is what is meant by "template" or "parameterized type". A template is kind of like a C++ class except that you can specify parameters to the template to indicate what types it should operate upon. The virtue of this approach is that one can implement an algorithm once, say for sorting a list, and then use the algorithm for any types of data that would be in a list --
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: numbers, strings, class objects, and so on. Templates are a little bit like C macros, and STL is distributed as a set of header files. Combining a template with particular argument types is a process known as "instantiation", and a template bound to particular arguments is known as a "template class". So, for example, template <class T> class List { . .. }; is a List template declaration, and List<double> dlist; declares a variable "dlist" of the template class List<double>, which is instantiated by supplying the type argument "double" to the List template. You can find out more about STL via this Web site: http://www.cs.rpi.edu/~musser/stl.html or download an implementation of the library via FTP from: butler.hpl.hp.com...
View Full Document

This note was uploaded on 02/27/2012 for the course CS 251 taught by Professor Staff during the Fall '08 term at Purdue University-West Lafayette.

Ask a homework question - tutors are online