www.easyCPlusPlus.com

Easy C++

www.easyCPlusPlus.com

STL Tutorial - Overview of the Standard Template Library

Introduction - What is the STL?

by John Kopp

Support this site at no cost to you

The Standard Template Library, or STL, is a collection of container classes, generic algorithms and related components that can greatly simplify many programming tasks in C++. The container classes, as you might surmise from the name, are classes used to hold objects of any particular type. Among the methods of the container classes are methods to add and remove elements, return elements and return iterators. Iterators are an abstraction of pointers. They provide a means to traverse containers and access objects within containers. The generic algorithms are a collection of routines that can be used to perform common operations on container classes, such as sorting, merging and finding. The are called generic because they are independent of the container class used and of the datatype of the objects held in those container classes. The iterators are used to link a container with an algorithm. A container class has methods to return iterators that provide access to its contents. These iterators are provided, as arguments, to an algorithm. The algorithm can then traverse, access and manipulate the contents of the container.

This lesson introduces the components of the STL and provides some simple examples. The rest of the lessons of the tutorial will examine each of these components in greater detail.

Previous Page       Next Page