What is the STL in C++?
Updated 2026-07-10 · Beginner friendly
Quick answer
The STL, or Standard Template Library, is a collection of ready made template classes and functions in C++. It has three main parts: containers like vector and map that store data, algorithms like sort and find that operate on data, and iterators that connect the two by walking through containers. It saves you from writing common data structures and algorithms yourself.
The three main parts
- Containers: vector, list, map, set, and more for storing data.
- Algorithms: sort, find, count, and others that process data.
- Iterators: objects that point into a container so algorithms can traverse it.
#include <vector>
#include <algorithm>
std::vector<int> v = {3, 1, 2};
std::sort(v.begin(), v.end()); // container + algorithm + iterators
In the interview
A common follow up is which container you would use for a task. Practice quick choices like vector for a dynamic array, map for key lookups, and set for unique sorted values. Matching container to need is the practical skill.
Common follow up questions
Related interview questions
Want the full C++ guide?
Read every C++ concept with notes, diagrams, and code in one place. Track your progress as you go.
Open the C++ guide All C++ questions