c++ map 不允许 string 为键值

#include <map>
using namespace std;
typedef map<string, float> StringFloatMap;

int main()
{
return 0;
}
编译不通过 错误说3 13 [Error] 'string' was not declared in this scope

第1个回答  2015-05-28
'string'没有声明, 应该是没#include <string>吧追问

哦哦哦 谢谢了,太感谢了。对了 我还有个问题就是,如果不用map可以实现关联数组吗?

追答

没试过, 办法应该有, 不过我不会 XD

本回答被提问者采纳
第2个回答  2021-07-30
也是可以的,只不过需要重载比较规则。
相似回答