Standard Template Library
Introduction
STL provides containers, iterators, and algorithms built on templates.
Definition
STL: Standard Template Library (containers, iterators, algorithms).
C++ Code Example
#include
#include
#include
using namespace std;
int main(){
vector v={3,1,2};
sort(v.begin(),v.end());
for(int x:v) cout< Important Questions
Short Questions
- What is STL?
- Components of STL?
- Name containers.
- Name algorithms.
Long Questions
- Explain STL components.
- Discuss vector and sort.
MCQ Practice
1. STL stands for:
- Standard Template Library
- Standard Type Library
- Simple Template Library
- System Template Library
Answer: Standard Template Library.
2. STL components:
- Containers, iterators, algorithms
- Only classes
- Only functions
- None
Answer: Containers, iterators, algorithms.
3. vector is a:
- Container
- Algorithm
- Iterator
- None
Answer: Container.
4. sort is an:
- Algorithm
- Container
- Iterator
- None
Answer: Algorithm.
5. STL is based on:
- Templates
- Inheritance
- Virtual functions
- None
Answer: Templates.
Quick Revision
- STL = containers + iterators + algorithms.
- Built on templates.