|
-
February 9th, 2003, 08:37 AM
#1
Compiling error on my simple STL spell-checker.
Hi, everyone!
Here is my simple STL program, it is a spell-checker.
The program copy every word of text to output
that is not in the dictionary. I have added all the source
codes and error messages below. My IDE is VC6.0.
Source Codes:
--------
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <fstream>
using namespace std;
template <class bidirectional_iterator, class T>
class nonAssocFinder {
public:
nonAssocFinder(bidirectional_iterator begin,
bidirectional_iterator end) :
_begin(begin), _end(end) {}
bool operator() (const T& word) {
return binary_search(_begin, _end, word); }
private:
bidirectional_iterator _begin;
bidirectional_iterator _end;
};
void main()
{
typedef vector<string > dict_type;
ifstream dictFile("dict.txt");
ifstream wordsFile("words.txt");
dict_type dictionary;
copy (istream_iterator<string>(dictFile),
istream_iterator<string>(),
back_inserter(dictionary));
remove_copy_if (
istream_iterator<string>(wordsFile),
istream_iterator<string>(),
ostream_iterator<string>(cout, "\n"),
nonAssocFinder<dict_type::iterator,
dict_type::value_type>
(dictionary.begin(), dictionary.end()));
}
--------
Warning and error messages:
--------
C:\Program Files\Microsoft Visual Studio\MyProjects\testDict\testDict.cpp(45) : warning C4786:
'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const
*,std::basic_string<char,std::char_traits<char>,std::all
ocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const
&,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,int>' : identifier was truncated to '255'
characters in the debug information
C:\Program Files\Microsoft Visual Studio\MyProjects\testDict\testDict.cpp(45) : warning C4786:
'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> >
*,std::basic_string<char,std::char_traits<char>,std::allocator
<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >
&,std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,int>' : identifier was truncated to '255' characters
in the debug information
c:\program files\microsoft visual studio\vc98\include\iterator(176) : error C2679: binary '>>' : no operator defined which
takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
(
or there is no acceptable conversion)
c:\program files\microsoft visual studio\vc98\include\iterator(176) : while compiling class-template member function
'void __thiscall std::istream_iterator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char>
>,char,struct std::char_traits<char> >::_Getval(void)'
--------
How to resolve the trouble?
Thanks in advance,
George
-
February 9th, 2003, 11:58 AM
#2
remove warnings
George2,
The warnings are harmless, nevertheless you can remove the warnings in VC6 with
Code:
#pragma warning(disable : 4786)
placed at the top of your C++ or header file.
I think the error is of some concern. You might have to write a global operator >> for some user-defined type in the class. I did not really study the example very closely and can not clearly indicate a solution.
Chris.
You're gonna go blind staring into that box all day.
-
February 9th, 2003, 01:35 PM
#3
dude_1967 is right about the warnings. As far as the error is
concerned, have you thought about "#include <string>" ?
-
February 10th, 2003, 06:15 AM
#4
Thanks, PaulWendt buddies!
George
Originally posted by PaulWendt
dude_1967 is right about the warnings. As far as the error is
concerned, have you thought about "#include <string>" ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|