🔴 Advanced · Lesson 53
Standard Template Library (STL)
Standard Template Library (STL)
What is Standard Template Library (STL)?
Standard Template Library (STL)
STL is a powerful C++ library containing containers, iterators, algorithms and function objects. It helps write shorter and efficient programs.
STL is a powerful C++ library containing containers, iterators, algorithms and function objects. It helps write shorter and efficient programs.
Level
🔴 STL, Modern C++ and Projects
🔴 STL, Modern C++ and Projects
Example File
stl-introduction.cppMain Focus
Concept + syntax + practical C++ program
Concept + syntax + practical C++ program
Why should you learn this?
- It helps you write correct and readable C++ programs.
- It is used repeatedly in school practicals, projects and competitive programming.
- It builds the base for advanced topics such as OOP, STL and data structures.
Important Terms
| Term | Meaning / Use |
|---|---|
| container | Standard Template Library (STL) programming में Container use होता है। |
| iterator | Standard Template Library (STL) programming में Iterator use होता है। |
| algorithm | Standard Template Library (STL) programming में Algorithm use होता है। |
| vector | Standard Template Library (STL) programming में Vector use होता है। |
| map | Standard Template Library (STL) programming में Map use होता है। |
Syntax / Pattern
C++
Use containers like vector, set, map and algorithms like sort().
Example Program
main.cpp
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
vector<int> v = {3,1,2};
sort(v.begin(), v.end());
for(int x : v) cout << x << " ";
}Expected Output
1 2 3
Program Explanation
- vector stores numbers.
- sort() arranges them in ascending order.
Exam Tip: In C++ practical answers, write the logic first, then the program, then expected output. For theory, always include one suitable example.
Where will you use it?
- competitive programming
- data processing
- fast development
Common Mistakes
- Reinventing common data structures unnecessarily.
- Using algorithm without including correct header.
Practice Tasks
- List four STL containers.
- Sort marks using vector.
Summary
Standard Template Library (STL) एक ज़रूरी C++ topic है। परिभाषा सीखें, syntax समझें, example program चलाएं और फिर practice tasks हल करके concept मज़बूत करें।
Standard Template Library (STL) क्या है?
Standard Template Library (STL)
STL is a powerful C++ library containing containers, iterators, algorithms and function objects. It helps write shorter and efficient programs.
STL is a powerful C++ library containing containers, iterators, algorithms and function objects. It helps write shorter and efficient programs.
Level
🔴 STL, Modern C++ and Projects
🔴 STL, Modern C++ and Projects
Example File
stl-introduction.cppमुख्य फोकस
Concept + syntax + practical C++ program
Concept + syntax + practical C++ program
इसे क्यों सीखें?
- यह आपको सही और पढ़ने-योग्य C++ programs लिखने में मदद करता है।
- यह school practicals, projects और competitive programming में बार-बार use होता है।
- यह OOP, STL और data structures जैसे advanced topics की नींव बनाता है।
ज़रूरी Terms
| Term | अर्थ / उपयोग |
|---|---|
| container | Container Standard Template Library (STL) programming में use होता है। |
| iterator | Iterator Standard Template Library (STL) programming में use होता है। |
| algorithm | Algorithm Standard Template Library (STL) programming में use होता है। |
| vector | Vector Standard Template Library (STL) programming में use होता है। |
| map | Map Standard Template Library (STL) programming में use होता है। |
Syntax / Pattern
C++
Use containers like vector, set, map and algorithms like sort().
Example Program
main.cpp
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
vector<int> v = {3,1,2};
sort(v.begin(), v.end());
for(int x : v) cout << x << " ";
}Expected Output
1 2 3
Program Explanation
- vector stores numbers.
- sort() arranges them in ascending order.
Exam Tip: In C++ practical answers, write the logic first, then the program, then expected output. For theory, always include one suitable example.
Where will you use it?
- competitive programming
- data processing
- fast development
आम गलतियाँ (Common Mistakes)
- Reinventing common data structures unnecessarily.
- Using algorithm without including correct header.
अभ्यास (Practice Tasks)
- List four STL containers.
- Sort marks using vector.
सारांश
Standard Template Library (STL) एक ज़रूरी C++ topic है। परिभाषा सीखें, syntax समझें, example program चलाएं और फिर practice tasks हल करके concept मज़बूत करें।
💻 Live Code Editor
Is page ke program yahan ready hain — chalाएं, badlें aur seekhें. Bina kuch install kiye.
Powered by OneCompiler. Editor mein code apne aap aa jata hai — Run dabaakर output dekhें.
Agar load na ho to naye tab mein kholें.