第一次使用unordered_map
最開始引入#include<unordered_map>,但是報錯:[Error] 'unordered_map' was not declared in this scope
解決辦法:
引入#include<tr1/unordered_map>並且使用using namespace std::tr1;
#include "solution.h"
//#include<unordered_map>
#include<algorithm>
#include<tr1/unordered_map>
using namespace std::tr1;
這是因爲:
在c++11以前要使用unordered_map需要
#include<tr1/unordered_map>//在unordered_map之前加上tr1庫名,
using namespace std::tr1;//與此同時需要加上命名空間
說明:是在devc++中使用出現了這個問題,在vs中不存在,可能是devc++環境比較老了
另外:在devc++中設置C++11:
Tools -> Complier Options -> Settings -> Code Generation -> Language Standard(-std) -> ISO c++11
參考鏈接:https://blog.csdn.net/u012530451/article/details/53228098謝謝