| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1266 人关注过本帖
标题:关于定义"string"型的堆栈的问题
只看楼主 加入收藏
ddsxd
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-3-22
收藏
 问题点数:0 回复次数:8 
关于定义"string"型的堆栈的问题
vc6.0(sp6)
调程序时,出现6个warning,为了确定问题所在,我编译如下源代码:
#include <iostream>
#include <stack>
#include <string>
using namespace std;
void main()
{
stack<string> n;
}
出现6个“warning”,这是什么原因?问题出在哪里?
编译结果:
Compiling...
test.cpp
d:\program files\vc98\include\deque(208) : warning C4786: 'std::reverse_iterator<std::deque<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >:
:const_iterator,std::basic_string<char,std::char_traits<char>,std::allocator<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>' : id
entifier was truncated to '255' characters in the debug information
d:\program files\vc98\include\deque(207) : while compiling class-template member function '__thiscall std::deque<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::deque<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >(void)'
d:\program files\vc98\include\deque(208) : warning C4786: 'std::reverse_iterator<std::deque<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >:
: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> > *,int>' : identifier was trunc
ated to '255' characters in the debug information
d:\program files\vc98\include\deque(207) : while compiling class-template member function '__thiscall std::deque<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::deque<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >(void)'
warning C4786: 'std::stack<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::deque<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocat
or<char> > > > >::~stack<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::deque<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator
<char> > > > >' : identifier was truncated to '255' characters in the debug information
d:\program files\vc98\include\stack(22) : warning C4786: 'std::stack<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::deque<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_strin
g<char,std::char_traits<char>,std::allocator<char> > > > >::stack<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::deque<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<c
har,std::char_traits<char>,std::allocator<char> > > > >' : identifier was truncated to '255' characters in the debug information
d:\program files\vc98\include\deque(208) : warning C4786: 'std::deque<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::~deque<std::basic_str
ing<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' : identifier was truncated to '255' characters in the debug information
d:\program files\vc98\include\deque(191) : warning C4786: 'std::deque<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::deque<std::basic_stri
ng<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' : identifier was truncated to '255' characters in the debug information

test.obj - 0 error(s), 6 warning(s)

搜索更多相关主题的帖子: std string 堆栈 源代码 定义 
2007-04-25 11:31
aipb2007
Rank: 8Rank: 8
来 自:CQU
等 级:贵宾
威 望:40
帖 子:2879
专家分:7
注 册:2007-3-18
收藏
得分:0 
不管他,编译器问题哦!

不要写void main()

Fight  to win  or  die...
2007-04-25 11:41
I喜欢c
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:64
帖 子:1749
专家分:0
注 册:2007-3-2
收藏
得分:0 

 我是指针,却丢失了目标地址!          我是循环,却缺少了结束条件!      我是函数,却没有人来调用!   
2007-04-25 12:49
leeco
Rank: 4
等 级:贵宾
威 望:10
帖 子:1029
专家分:177
注 册:2007-5-10
收藏
得分:0 
很正常,我写有过100多warning的程序,就是string引起的。
2007-05-16 19:23
xvholly
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2007-1-31
收藏
得分:0 
以下是引用aipb2007在2007-4-25 11:41:07的发言:

不要写void main()

请教一下,为什么不要这么写?


2007-05-16 20:27
yushui
Rank: 3Rank: 3
等 级:论坛游民
威 望:7
帖 子:1355
专家分:22
注 册:2006-7-19
收藏
得分:0 

C-Free里面没有这个问题 但有些vc6能编译通过的C-Free就不能通过了 就不清楚怎么回事 


fighting!from now on!
2007-05-16 21:04
yuyunliuhen
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1435
专家分:0
注 册:2005-12-12
收藏
得分:0 
以下是引用xvholly在2007-5-16 20:27:26的发言:

请教一下,为什么不要这么写?

main() 必须声明为返回 int, 且没有参数或者接受适当类型的两个参数。如果你调用了 exit() 但还是有警告信息, 你可能需要插入一条冗余的 return 语句 (或者使用某种 ``未到达" 指令, 如果有的话)。
把函数声明为 void 并不仅仅关掉了警告信息:它可能导致与调用者(对于 main(), 就是 C 运行期初始代码) 期待的不同的函数调用/返回顺序。


Go confidently in the  directions of your dreams,live the life you have imagined!Just do it!
It is no use learning without thinking!
2007-05-16 21:41
yuyunliuhen
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1435
专家分:0
注 册:2005-12-12
收藏
得分:0 
int main(), int main(void) 或者 int main(int argc, char *argv[]) ( argc 和 argv 的拼写可以随便)。

Go confidently in the  directions of your dreams,live the life you have imagined!Just do it!
It is no use learning without thinking!
2007-05-16 21:50
icedge
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2007-5-13
收藏
得分:0 
我用vc++2005直接复制楼主的代码没有任何的错误或警告。
2007-05-16 23:50
快速回复:关于定义"string"型的堆栈的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026479 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved