using the find_if() function in c++ -


i errors use find_if function. says no matching function. did find others have come through error, couldn't quite understand replies. please can 1 correct & explain mistakes are? appreciated. in advance.

//another way split strings  #include<iostream> #include<string> #include<algorithm> #include<vector>  using std::endl; using std::cout; using std::cin; using std::string; using std::vector; using std::istream;  istream& getwords(istream&, vector<string>&); string& removedelimeters(string&); bool space(char); bool not_space(char); void display(const vector<string>&);  int main() {     vector<string> words;      getwords(cin,words);     display(words);      return 0; }  void display(const vector<string>& vec) {     cout<<endl;     for(vector<string>::const_iterator iter = vec.begin();iter != vec.end();iter++)     {         cout<<*iter<<endl;     } }  bool space(char c) {     return isspace(c); }  bool not_space(char c) {     return !isspace(c); }  string& removedelimeters(string& word) {     string delim = ",.`~!@#$%^&*()_+=-{}][:';?><|";      for(unsigned int = 0;i<word.size();i++)     {         for(unsigned int j = 0;j<delim.size();j++)         {             if(word[i] == delim[j])             {                 word.erase(word.begin()+i);     //removes value @ given index                 break;             }         }     }      return word; }  istream& getwords(istream& in, vector<string>& vec) {     typedef string::const_iterator iter;      string initial;      cout<<"enter initial sentance : ";     getline(cin,initial);      initial = removedelimeters(initial);      iter = initial.begin();     while(i != initial.end())     {         //ignore leading blanks         = find_if(i,initial.end(),not_space);          //find end of word         iter j = find_if(j,initial.end(),space);          //copy characters in [i,j)         if(i != initial.end())         {             vec.push_back(string(i,j));         }          = j;     } } 

aside using std::find_if mentioned john dibling, , whole host of other issues (look @ getwords method , it's doing passed in stream, , return type? etc.)

your main problem passing in 2 different iterator types find_if, first iterator const_iterator - because assign const_iterator, second iterator non const, i.e. initial.begin() - because initial not const - , const/non const iterators different types, why won't find find_if match...


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -