谢谢各位帮忙解决!!

xujun888 2003-11-28 10:45:51
这是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);

};
...全文
36 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
tangsongxp 2003-11-28
  • 打赏
  • 举报
回复
不同意楼上的说法,warning的出现的确不影响编译,但是有些warning可是会导致语义错误(semantics error)的,所以最好确保编译程序时没有warning的出现。
mousemice 2003-11-28
  • 打赏
  • 举报
回复
我课程设计一道题目用到deque<string>

一个程序一个有52个类似的warning

但程序照样运行得很好^_^
kdush 2003-11-28
  • 打赏
  • 举报
回复
可能是头文件的事,C++的兼容性并不是我们想象的那样好,很多C++的编辑器都有它自己的类库,
这使得C++的可移植性大大降低。
我想C++ primer 不会出错吧,你换个编辑器试试!

64,637

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧