I wrote this code to remove consonants from string but my answer is not correct. So what change should i make in this code to make it work correctly. Further more when i remove the space character i.e. last element from unordered set then the output was unexpected to me. So please help me understanding what is going on in this code??
#include<bits/stdc++.h>
using namespace std;
int main() {
   unordered_set<char> a={'a','e','i','o','O','u','U','A','E','I',' '};
   string s="what are you doing";
   string ::iterator it;
   for(it=s.begin();it!=s.end();it++){
      if(a.find(*it)==a.end()){
         s.erase(it);}
    }   
    cout<<s;
    return 0;
}
 
     
    