Templates are recipes with a placeholder type; the STL is a giant toolbox built from exactly that idea.
1 template = recipe
You write the logic once; the compiler stamps out a real copy for each type you use.
2 typename T
T is the placeholder. Write T in the recipe, pass int or double at the call — the compiler fills it in.
3 STL containers
vector, map and set are all templates — std::vector<int> stamps the array for ints.
4 STL algorithms
sort, find and friends work on any container — generic code you never have to write.
Generic power
template = recipe1You write the logic once; the compiler stamps out a real copy for each type you use. typename T2T is the placeholder. Write T in the recipe, pass int or double at the call — the compiler fills it in. STL containers3vector, map and set are all templates — std::vector<int> stamps the array for ints. STL algorithms4sort, find and friends work on any container — generic code you never have to write. 4 building blocks make up Generic power
Nothing generic survives into the binary — the compiler stamps one real version per type.
Two tabs: push_back fills a vector step by step, then one template function serves two types.
preprocessThe preprocessor pastes in iostream for cout.
Memory
no variables yet — press play
Console
output appears as the program runs…
Grow, overwrite, print — what does this vector program output?
Your predicted output — one line per console line
Hint: push_back appends at the end. nums[1] = 100 overwrites the middle element — size stays 3.
Click a term, then click its description to lock the pair.
5 conceptsTap a card to expand ?template <typename T>drops into place
?std::vector<int>drops into place
?push_backdrops into place
?size()drops into place
?std::sortdrops into place
01Templates are recipes: the compiler stamps one real version per type.
02Write biggest<T> once — it works for int, double and your own classes.
03vector is the STL everyday hero: growable, indexed, self-managing.
04Valid indexes run 0 .. size() - 1 — never past the end.
05The STL ships containers (vector, map) and algorithms (sort, find).