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
等等......请问这是怎么回事?编译器问题?改怎么办? 展开
#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
等等......请问这是怎么回事?编译器问题?改怎么办? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询