C++ error: 'unordered_map' does not name a type

前端 未结 3 930
感动是毒
感动是毒 2021-01-08 00:41

I am doing everything correctly as far as I can tell and I have gotten the error message:

error: \'unordered_map\' does not name a type
error: \'mymap\' does         


        
3条回答
  •  南笙
    南笙 (楼主)
    2021-01-08 01:05

    You can't execute arbitrary expressions at global scope, so you should put

    mymap.reserve(7000);
    

    inside main.

    This is also true for other STL containers like map and vector.

提交回复
热议问题