Skip to content

Instantly share code, notes, and snippets.

@abrarShariar
Created December 29, 2015 09:23
Show Gist options
  • Save abrarShariar/b80abd49cf2783e69480 to your computer and use it in GitHub Desktop.
Save abrarShariar/b80abd49cf2783e69480 to your computer and use it in GitHub Desktop.
Demo of set::erase(), empty() , insert()
#include<iostream>
#include<set>
using namespace std;
int main(){
set<char>mySet;
for(char ch='a';ch<='z';ch++){
mySet.insert(ch);
}
//display
while(!mySet.empty()){
for(auto it=mySet.begin();it!=mySet.end();it++){
cout<<*it<<" ";
}
char del;
cout<<"Delete: ";
cin>>del;
mySet.erase(del);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment