📘 Lesson  ·  Lesson 74

STL Overview

What is the STL?

💡 Note

The STL (Standard Template Library) provides ready-made containers (vector, map, set), algorithms (sort, find) and iterators.

Main Parts

  • Containers — vector, list, map, set, stack, queue.
  • Algorithms — sort, find, count, reverse.
  • Iterators — move through containers.

Example

C++
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    vector<int> v = {5, 2, 8, 1};
    sort(v.begin(), v.end());   // STL algorithm
    for (int x : v) cout << x << " ";   // 1 2 5 8
    return 0;
}
Output:
1 2 5 8

Summary

  • STL = containers + algorithms + iterators, ready to use.
  • Saves time vs writing data structures from scratch.

the STL क्या है?

💡 Note

The STL (Standard Template Library) provides ready-made containers (vector, map, set), algorithms (sort, find) and iterators.

Main Parts

  • Containers — vector, list, map, set, stack, queue.
  • Algorithms — sort, find, count, reverse.
  • Iterators — move through containers.

Example

C++
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    vector<int> v = {5, 2, 8, 1};
    sort(v.begin(), v.end());   // STL algorithm
    for (int x : v) cout << x << " ";   // 1 2 5 8
    return 0;
}
Output:
1 2 5 8

सारांश

  • STL = containers + algorithms + iterators, ready to use.
  • Saves time vs writing data structures from scratch.
← Back to C++ Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

💻 लाइव कोड एडिटर

इस पेज के प्रोग्राम यहीं तैयार हैं — चलाएँ, बदलें और सीखें। कुछ भी इंस्टॉल किए बिना।
OneCompiler द्वारा संचालित। कोड एडिटर में अपने आप आ जाता है — Run दबाकर आउटपुट देखें। अगर एडिटर न खुले तो नए टैब में खोलें.