Lecture 10
Learning objectives
After this class, you should be able to:
- Describe the purpose of the following components of the standard template library: (i) containers, (ii) iterators, (iii) functionals, and (iv) algorithms.
- Write code that uses the following STL algorithms: (i) for_each, (ii) sort, and (iii) reverse.
- Look up an STL reference and write code that uses some feature that you are asked to use.
- Define and use function classes/objects.
Reading assignment
- Section 1.6.4, STL reference, class notes.
- Lecture: STL algorithms.
- Figures 3.14, 3.15.
Exercises and review questions
- Exercises and review questions on current lecture's material
- Write a program that will define a variable of STL's
list
type, so that it can store int
s. Then insert a few integers into it, and use for_each
and a function object to output its contents. Next, use a function object and sort
to sort the list in descending order.
- Questions on next lecture's material
- What is the difference between the two increment operator for iterators (with and without an
int
argument)?
Last modified: 20 Sep 2011