Speed up development with full-stack environments for every branch.

Learn More

Simple std::set example [C++ and Standard Template Library]

Forked from Hello World C++ Example.

12525 Runs 57811 Views 15916 Copies
Saved

Saved

pearmaster 12

pearmaster
published 3 years ago

#include <iostream>

#include <set>

int main ()
{
  std::set<std::string> s;
  std::cout << "Adding 'Hello' and 'World' to the set twice" << std::endl;
  
  s.insert("Hello");
  s.insert("World");
  s.insert("Hello");
  s.insert("World");
  
  std::cout << "Set contains:";
  while (!s.empty()) {
    std::cout << ' ' << *s.begin();
    s.erase(s.begin());
  }
  
  return 0;
}
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).