In lineCode:#include <iostream> #include <list> #include <algorithm> #include <set> #include <iterator> using namespace std; int main() { set<string> words; list<string> index; for(string new_word; cin >> new_word, new_word != "Quit"; ) { pair<set<string>::iterator, bool> &trace = words.insert(new_word); if(trace.second) index.push_back(trace.first); } copy(index.begin(), index.end(), ostream_iterator<string>(cout, "\n")); copy(words.begin(), words.end(), ostream_iterator<string>(cout, "\n")); return 0; }
pair<set<string>::iterator, bool> &trace = words.insert(new_word);
it says
invalid initialization of non-const reference of type 'std:air<std::_Rb_tree_const_iterator<std::string>, bool>&' from a temporary of type 'std:
air<std::_Rb_tree_const_iterator<std::string>, bool>'
I took the code from a book so i'm confused on why it won't work...



LinkBack URL
About LinkBacks
air<std::_Rb_tree_const_iterator<std::string>, bool>&' from a temporary of type 'std:



