Containers in C++ STL


In this tutorial, we will be discussing a program to understand containers in C++ STL.

Containers are the objects used to store multiple elements of the same type or different. Depending on that they can be further classified as −

  • Sequence containers (array, vector, list)

  • Associative containers (set, map, multimap)

  • Unordered Associative containers (unordered_set, unordered_map)

  • Container Adapters (stack, queue)

Example

 Live Demo

#include <iostream>
using namespace std;
int main(){
   int array[10] = {1,2,3,4};
   for(int i=0; i<10; i++){
      cout << array[i] << " ";
   }
   return 0;
}

Output

1 2 3 4 0 0 0 0 0 0

Updated on: 12-Mar-2020

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements