C++ Sets

C++ Set

A set stores unique elements where they:

  • Are sorted automatically in ascending order.
  • Are unique, meaning equal or duplicate values are ignored.
  • Can be added or removed, but the value of an existing element cannot be changed.
  • Cannot be accessed by index numbers, because the order is based on sorting and not indexing.

To use a set, you have to include the <set> header file:

// Include the set library
#include <set>

Continue reading C++ Sets