Object Oriented Programming
(CSC-213)
Lecture 21: Standard Template
Library (STL)
STL IS A SET OF C++ TEMPLATE CLASSES
TO PROVIDE COMMON PROGRAMMING
DATA STRUCTURES AND FUNCTIONS SUCH
AS LISTS, STACKS, ARRAYS, ETC.
LIBRARY OF CONTAINER CLASSES,
ALGORITHMS AND ITERATORS
IT IS A GENERALIZED LIBRARY AND SO,
ITS COMPONENTS ARE PARAMETERIZED
STL Components
• Algorithms
• Containers
• Functions
• Iterators
Containers
• Sequence containers
– Vector
– List
– Deque
– Arrays
– Forward_list
• Container adaptors
• Associative containers
VECTORS ARE SAME AS DYNAMIC
ARRAYS WITH THE ABILITY TO
RESIZE ITSELF AUTOMATICALLY
WHEN AN ELEMENT IS INSERTED OR
DELETED, WITH THEIR STORAGE
BEING HANDLED AUTOMATICALLY BY
THE CONTAINER.
Vector
I have covered a very minimal part of the
vector stl, you can look up more details and
use in your project. Quiz and exam will
include the parts I have covered today.
https://www.learncpp.com/cpp-tutorial/introdu
ction-to-stdvector-and-list-constructors/
Robot Army Example: This is a partial
example giving a demo of several techniques
you can use in your project. As an exercise,
find and fix the memory leak issue.
Material adapted from
https://www.geeksforgeeks.org/the-c-standard-template-library-stl/
https://www.geeksforgeeks.org/vector-in-cpp-stl/

Standard Template Library Standard Template Library