Error “xxxx”does not name a type

前端 未结 3 2135
花落未央
花落未央 2021-02-20 01:47

I encountered a problem when tried compiling the following code:

#include 
#include 
#include 
#include 

        
3条回答
  •  被撕碎了的回忆
    2021-02-20 02:18

    When you declare a variable in global scope, you may only do initialization. E.g,

    int a = 0;
    

    You cannot do normal statements like:

    a = 9;
    

    So I would fix the code with:

    #include 
    #include 
    #include 
    #include 
    #include 
    
    using namespace std;
    
    map mapDial;
    
    int main()
    {
      mapDial['A'] = 2;
      cout << mapDial['A'] << endl;
      return 0;
    }
    

提交回复
热议问题