Standard Template Library

Unit 4 Β· Topic 4.7⏱ 8 min read❓ 5 MCQs

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

  1. What is STL?
  2. Components of STL?
  3. Name containers.
  4. Name algorithms.

Long Questions

  1. Explain STL components.
  2. 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.