map.find 编译不通过,不知道为何?
#include <map>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
map <string , int > m_Slot;
string s( "1 ");
m_Slot[s] = 1;
s = "2 ";
m_Slot[s] = 2;
m_Slot.find( s ); // compiling failed! why?
return 0;
}
以上代码在visual 2005 中编译不通过。为什么?
如果把string换成别的数据类型,调用find能通过的。为什么用string不行呢?
[解决办法]
应该是你漏了 #include <string> ,导致map模版参数推导出错。
[解决办法]
#include <string>