vc6.0使用map容器发生错误

代码如下:#include<iostream>#include<string>#include<map>usingnamespacestd;intmain(){map<s... 代码如下:
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main()
{
map<string, int> ma;
string word;
while(cin >> word)
++ma[word];
for(map<string,int>::iterator ix = ma.begin(); ix != ma.end(); ++ix)
cout << (*ix).first << " " << (*ix).second << endl;
return 0;
}

出现21 error(s), 0 warning(s):
f:\vc98\include\xtree(629) : error C2059: syntax error : '?'
f:\vc98\include\xtree(629) : error C2065: '_Y' : undeclared identifier
f:\vc98\include\xtree(629) : error C2275: '_A' : illegal use of this type as an expression
f:\vc98\include\xtree(629) : error C2143: syntax error : missing ',' before ')'
f:\vc98\include\xtree(631) : error C2951: template declarations are only permitted at global or namespace scope
f:\vc98\include\xtree(632) : error C2976: '_Tree' : too few template arguments
f:\vc98\include\xtree(602) : see declaration of '_Tree'
f:\vc98\include\xtree(633) : error C2143: syntax error : missing ',' before '<='
f:\vc98\include\xtree(633) : error C2433: 'bool' : 'inline' not permitted on data declarations
f:\vc98\include\xtree(633) : error C2059: syntax error : 'operator <op>'
f:\vc98\include\xtree(635) : error C2143: syntax error : missing ')' before '{'
f:\vc98\include\xtree(635) : error C2059: syntax error : '{'
f:\vc98\include\xtree(635) : error C2143: syntax error : missing ';' before '{'
f:\vc98\include\xtree(635) : error C2447: missing function header (old-style formal list?)
f:\vc98\include\xtree(636) : error C2954: template definitions cannot nest
f:\vc98\include\map(44) : error C2039: 'reference' : is not a member of '_A'
f:\vc98\include\xtree(632) : see declaration of '_A'
f:\vc98\include\map(140) : see reference to class template instantiation 'std::map<_K,_Ty,_Pr,_A>' being compiled
f:\vc98\include\map(44) : error C2146: syntax error : missing ';' before identifier '_Tref'
f:\vc98\include\map(140) : see reference to class template instantiation 'std::map<_K,_Ty,_Pr,_A>' being compiled
f:\vc98\include\map(44) : error C2501: '_Tref' : missing storage-class or type specifiers
f:\vc98\include\map(140) : see reference to class template instantiation 'std::map<_K,_Ty,_Pr,_A>' being compiled
f:\vc98\include\map(48) : error C2040: 'reference' : ' &' differs in levels of indirection from 'int'
f:\vc98\include\map(140) : see reference to class template instantiation 'std::map<_K,_Ty,_Pr,_A>' being compiled
f:\vc98\include\map(92) : error C2143: syntax error : missing ';' before '['
f:\vc98\include\map(140) : see reference to class template instantiation 'std::map<_K,_Ty,_Pr,_A>' being compiled

等等......请问这是怎么回事?编译器问题?改怎么办?
展开
 我来答
猪头或火宝宝
2010-08-16 · TA获得超过2758个赞
知道小有建树答主
回答量:1001
采纳率:0%
帮助的人:1514万
展开全部
是楼主的编译器有问题!!!!

我用c++ 6.0 运行完全正确!!!!

如下:

aaaa
bbbb
cccc
ssss
dddd
^Z
^Z
aaaa 1
bbbb 1
cccc 1
dddd 1
ssss 1
Press any key to continue
kakarot23
2010-08-16 · TA获得超过255个赞
知道小有建树答主
回答量:384
采纳率:0%
帮助的人:317万
展开全部
VC6对标准C++,特别是STL的支持很不好

建议用DEV C++ 或VS2005
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式