S
s
I'm getting compile errors on the following code:
<code>
#include <iostream>
#include <fstream>
#include <list>
#include <string>
using namespace std;
int main(void)
{
ifstream infile("expertonasia.txt", ios::in);
list <string> word_list;
list <string>::iterator word_list_it;
string word;
int word_count = 0;
bool found_match;
while(infile)
{
infile>>word;
word_list_it = word_list.find(word_list.begin(), word_list.end(),
word);
if( word_list_it != word_list.end() ) //new word
{
word_list.push_back(word);
}
}
infile.close();
//Any sorting?
word_list.sort(word_list.begin(), word_list.end());
}
</code
Produces the following compile errors:
<compile>
post.c++: In function `int main()':
post.c++:20: no matching function for call to `std::list<std::string,
std::allocator<std::string> >::find(std::_List_iterator<std::string,
std::string&, std::string*>, std::_List_iterator<std::string,
std::string&,
std::string*>, std::string&)'
post.c++:29: no matching function for call to `std::list<std::string,
std::allocator<std::string> >::sort(std::_List_iterator<std::string,
std::string&, std::string*>, std::_List_iterator<std::string,
std::string&,
std::string*>)'
/usr/include/c++/3.2/bits/stl_list.h:879: candidates are: void
std::list<_Tp,
_Alloc>::sort() [with _Tp = std::string, _Alloc =
std::allocator<std::string>]
</compile>
Can I use the find and sort algorithms on a list of string's???
Thanks,
Stephen
<code>
#include <iostream>
#include <fstream>
#include <list>
#include <string>
using namespace std;
int main(void)
{
ifstream infile("expertonasia.txt", ios::in);
list <string> word_list;
list <string>::iterator word_list_it;
string word;
int word_count = 0;
bool found_match;
while(infile)
{
infile>>word;
word_list_it = word_list.find(word_list.begin(), word_list.end(),
word);
if( word_list_it != word_list.end() ) //new word
{
word_list.push_back(word);
}
}
infile.close();
//Any sorting?
word_list.sort(word_list.begin(), word_list.end());
}
</code
Produces the following compile errors:
<compile>
post.c++: In function `int main()':
post.c++:20: no matching function for call to `std::list<std::string,
std::allocator<std::string> >::find(std::_List_iterator<std::string,
std::string&, std::string*>, std::_List_iterator<std::string,
std::string&,
std::string*>, std::string&)'
post.c++:29: no matching function for call to `std::list<std::string,
std::allocator<std::string> >::sort(std::_List_iterator<std::string,
std::string&, std::string*>, std::_List_iterator<std::string,
std::string&,
std::string*>)'
/usr/include/c++/3.2/bits/stl_list.h:879: candidates are: void
std::list<_Tp,
_Alloc>::sort() [with _Tp = std::string, _Alloc =
std::allocator<std::string>]
</compile>
Can I use the find and sort algorithms on a list of string's???
Thanks,
Stephen