【C++】問題解決:cannot be initialized with an initializer list

問題描述

這是我在宣告 unordered_map 時,所碰到的問題

cannot be initialized with an initializer list

解決方法

這裡碰到的是 g++ 不支援 c++98 的標準問題,
因此只要更換至 c++11 以上即可。

  • 原來:
g++ unorder_map_test.cpp; ./a.out
  • 修改後:
g++ unorder_map_test.cpp -std=c++11; ./a.out

Reference

Licensed under CC BY-NC-SA 4.0