Lecture 3
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.
- Explain the difference between sequences and associative containers.
- Write code that uses the STL iterators.
- Write code that uses the following STL algorithms: (i) for_each, (ii) reverse, (iii) sort, and simple features of the following STL containers: (i) vector, (ii) list, and (iii) map.
- 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.7.
- www.sgi.com/tech/stl has a good reference on STL.
- Page 31 in the text.
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 an iterator to go through the entire list and output its contents.
- Repeat the above question, but use the
for_each
to help you perform the output.
- Look up an STL reference, and rewrite the
usepair.cpp
code so that it uses the STL's pair
class.
- Questions on next lecture's material
- Write a program that inserts the following
float
s into an STL vector
object: 3.1, 2.0, 4.1
.
Last modified: 15 Jan 2008