谢谢各位帮忙解决!!
这是C++Primer 259页的例子,照着打,出了好多错误,本人初学,谢谢各位大哥大姐告诉我错误原因,怎么改正,不甚感激!!
用的是VC++6.0
D:\program files\Microsoft Visual Studio\MyProjects\program\program.cpp(21) : warning C4786: 'std::pair<std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std
::allocator<char> > > > *,std::vector<std::pair<short,short>,std::allocator<std::pair<short,short> > > *>' : identifier was truncated to '255' characters in the debug information
D:\program files\Microsoft Visual Studio\MyProjects\program\program.cpp(21) : warning C4786: 'std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::vector<std::pair<short,short>,std::allocator<std::pair<short,short> > >
*,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::vector<std::pair<short,short>,std::allocator<std::pair<short,short> > > *> >' : identifier was truncated to '255' characters in the debug informat
ion
这些警告提示是么意思呀?
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <fstream.h>
#include <stddef.h>
#include <ctype.h>
using namespace std;
typedef pair<short,short> location;
typedef vector<location> loc;
typedef vector<string> text_;
typedef pair<text_ *,loc * > text_loc;
//类textquery 定义
class textquery{
public:
textquery(){memset(this,0,sizeof(textquery));} //这行有错
static void
filter_elements(string felems){filt_elems=felems;}
void query_text();
void dispaly_map_text();
void dispaly_text_locations();
void doit(){
retrieve_text();
separate_words();
filter_text();
suffix_text();
strip_caps();
bulid_word_map();
}
private:
void retrieve_text();
void separate_words();
void filter_text();
void suffix_text();
void strip_caps();
void bulid_word_map();
private:
vector<string> *lines_of_text; //这里如果加了allocator也出错
text_loc *text_locations;
map<string,loc*> *word_map;
static string filt_elems;
};
string textquery::filt_elems("\",.;:!?)(\\/");
int main()
{
textquery tq;
tq.doit();
tq.query_text();
tq.dispaly_map_text ();
return 0;
}
void textquery::retrieve_text()
{
string file_name;
cout<<"please enter file name";
cin>>file_name;
ifstream infile(file_name.c_str(),ios::in);
if(!infile)
{cerr<<"oops !unable to open file"<<file_name<<"----bailing out!\n";
exit (-1);
}
else cout<<"\n";
lines_of_text=new vector<string,allocator>;
string textline;
while(getline(infile,textline,'\n'))
lines_of_text->push_back(textline);
};