Object-Oriented C++
STL Containers
The Standard Template Library gives you ready-made data structures.
| Container | Use for |
|---|---|
vector | Dynamic list |
map | Sorted key-value pairs |
unordered_map | Fast key-value lookup |
set | Sorted unique values |
stack / queue | LIFO / FIFO |
pair | Two values together |
#include <map>
map<string, int> stock;
stock["apple"] = 10;
stock["mango"] = 4;
for (auto [fruit, qty] : stock) {
cout << fruit << " " << qty << endl;
}Output
apple 10 mango 4