std::map error: implicit instantiation of undefined template 不能识别std::map迭代器指针

来源:互联网 发布:js和php文件怎么运行 编辑:程序博客网 时间:2024/06/06 06:13

std::map error: implicit instantiation of undefined template 不能识别std::map迭代器指针

代码如下:

std::map<std::string, int>::iterator map_iter;map_iter->first

QT中报错:

/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/utility:258: error: implicit instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >'_T1 first;    ^

发现是引入头文件错误。

我原本头文件引入如下:

#include <stdio.h>#include <string.h>#include <map>

应该 #include <string>,而不是 #include <string.h>,修改为如下:

#include <iostream>#include <string>#include <map>
原创粉丝点击