STL Containers
#include <vector>
#include <map>
#include <string>
vector<int> v = {1, 2, 3, 4};
v.push_back(5);
map<string, int> m;
m = 25;
Templates
template<typename T>
T maximum(T a, T b) {
return (a > b) ? a : b;
}
cout << maximum(3, 7); // 7
cout << maximum(3.14, 2.7); // 3.14
Summary
- vector is the most used STL container
- Templates enable generic programming
YouTip