dimanche 23 août 2020

error: no match for ‘operator[]’ (operand types are ‘std::map

I wanted to test if the increment ++ works for the std::map :

#include <bits/stdc++.h>

using namespace std;
int main() 
{
   map<string, int> map;;
   map['1'] = 0;
   map['1']++;
   cout << map['1'] << endl;
   return 0;
}

And Ì get the error of the title for :

map['1'] = 0;

I do not understand why

Aucun commentaire:

Enregistrer un commentaire