lecture9 notes

Default values can be set for template parameters for

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 3 and 3.5 on separate lines. Here, one instance of the ArrayContainer class works on a 5-element array of ints whereas the other instance works on a 10-element array of floats. Default values can be set for template parameters. For example, the previous template definition could have been: template <typename T=int, int N=5> class ArrayContainer { ... } and we could have created an ArrayContainer using the default parameters by writing: ArrayContainer<> identifier; 2 Standard Template Library Part of the C++ Standard Library, the Standard Template Library (STL) contains many useful container classes and algorithms. As you might imagine, these various parts of the library are written using templates and so are generic in type. The containers found in the STL are lists, maps, queues, sets, stacks, and vectors. The algorithms include sequence operations, sorts, searches, merges, heap operations, and min/max operations. We will explore how to use some of these through example here...
View Full Document

This document was uploaded on 03/18/2014 for the course EECS 6.096 at MIT.

Ask a homework question - tutors are online