看过C++ Primer的过来帮帮我!
第六章最后那个例子!
这是出现错误代码的地方:
void TextQuery::build_word_map()
{
word_map = new map<string, loc*, less<string>, allocator<string> >;
typedef map<string, loc*, less<string>, allocator<string> >::value_type value_type;
typedef set<string, less<string>, allocator<string> >::difference_type diff_type;
set<string, less<string>, allocator<string> > exclusion_set;
ifstream infile("exclusion_set");
if(!infile)
{
static string default_excluded_words[25] = {"the", "and", "but", "that", "then", "are", "been", "can",
"can't", "cannot", "could", "did", "for", "had", "have", "him", "his", "her", "its", "into",
"were", "which", "when", "with", "would"};
cerr << "warning! unable to open word exclusion file! -- " << "using default set\n";
copy(default_excluded_words, default_excluded_words + 25, inserter(exclusion_set, exclusion_set.begin()));
}
else
{
istream_iterator<string, diff_type> input_set(infile), eos; //这里有错误!
//错误提示: 198 C:\Documents and Settings\Administrator\My Documents\Untitled2.cpp
//no matching function for call to `std::istream_iterator<std::string, diff_type,
copy(input_set, eos, inserter(exclusion_set, exclusion_set.begin()));
}
vector<string, allocator<string> > *text_words = text_locations->first;
vector<location, allocator<string> > *text_locs = text_locations->second;
register int elem_cnt = text_words->size();
for(int ix=0; ix<elem_cnt; ++ix)
{
string textword = (*text_words)[ix];
if((textword.size() < 3) || exclusion_set.count(textword))
continue;
if(!word_map->count((*text_words)[ix])) {
loc *ploc = new vector<location, allocator<string> >;
ploc->push_back((*text_locs)[ix]);
word_map->insert(value_type((*text_words)[ix], ploc));
}
else (*word_map)[(*text_words)[ix]]->push_back((*text_locs)[ix]);
}
}
各位一定要帮帮我啊!
这是出现错误代码的地方:
void TextQuery::build_word_map()
{
word_map = new map<string, loc*, less<string>, allocator<string> >;
typedef map<string, loc*, less<string>, allocator<string> >::value_type value_type;
typedef set<string, less<string>, allocator<string> >::difference_type diff_type;
set<string, less<string>, allocator<string> > exclusion_set;
ifstream infile("exclusion_set");
if(!infile)
{
static string default_excluded_words[25] = {"the", "and", "but", "that", "then", "are", "been", "can",
"can't", "cannot", "could", "did", "for", "had", "have", "him", "his", "her", "its", "into",
"were", "which", "when", "with", "would"};
cerr << "warning! unable to open word exclusion file! -- " << "using default set\n";
copy(default_excluded_words, default_excluded_words + 25, inserter(exclusion_set, exclusion_set.begin()));
}
else
{
istream_iterator<string, diff_type> input_set(infile), eos; //这里有错误!
//错误提示: 198 C:\Documents and Settings\Administrator\My Documents\Untitled2.cpp
//no matching function for call to `std::istream_iterator<std::string, diff_type,
copy(input_set, eos, inserter(exclusion_set, exclusion_set.begin()));
}
vector<string, allocator<string> > *text_words = text_locations->first;
vector<location, allocator<string> > *text_locs = text_locations->second;
register int elem_cnt = text_words->size();
for(int ix=0; ix<elem_cnt; ++ix)
{
string textword = (*text_words)[ix];
if((textword.size() < 3) || exclusion_set.count(textword))
continue;
if(!word_map->count((*text_words)[ix])) {
loc *ploc = new vector<location, allocator<string> >;
ploc->push_back((*text_locs)[ix]);
word_map->insert(value_type((*text_words)[ix], ploc));
}
else (*word_map)[(*text_words)[ix]]->push_back((*text_locs)[ix]);
}
}
各位一定要帮帮我啊!
...全文
相关推荐
C++ primer Plus的pdf资源
C++ primer Plus的pdf资源
Cpp-Primer_ch116.cpp_liquid8m5_cppprimer_c++primer_
标题中的"ch116.cpp_liquid8m5_cppprimer_c++primer_"可能表示这是一份与第116章相关的C++源代码示例,用于辅助学习《C++ Primer》的内容。"
cpp-primer-learning
总之,"cpp-primer-learning"提供了一个全面的C++入门平台,涵盖了从基本语法到高级特性的诸多方面。
cpp-primer-code.rar
这个名为"cpp-primer-code.rar"的压缩包文件很可能是该书的配套代码示例,用于辅助学习和实践C++编程。
cpp primer
### C++ Primer 知识点概览#### 标题:C++ Primer- **核心概念**:本书作为一本深入浅出介绍C++语言的教材,旨在为读者提供全面而系统的C++学习路径。


