How do I add deletion to my program??????

#include <iostream>
#include <set>
using namespace std;

int main ()
{
  set<int> myset;
  set<int>::iterator it;
  pair<set<int>::iterator,bool> ret;

  // set some initial values:
  for (int i=1; i<=5; i++) myset.insert(i*5);   

  ret = myset.insert(15);              

  if (ret.second==false) it=ret.first;  

  myset.insert (it,8);                 
  myset.insert (it,9);                 
  myset.insert (it,11);                 

  int myints[]= {5,10,15};              
  myset.insert (myints,myints+3);

  cout << "myset contains:";
  for (it=myset.begin(); it!=myset.end(); it++)
    cout << " " << *it;
  cout << endl;

  return 0;
}

Recommended Answers

All 2 Replies

You forgot to ask a question.

I think what you're looking for is erase.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.