I initialize the map map<string,int> ex; in c ++. I could not find contains_key or a similar function in stl, so I just use ex[inputString]++;
map<string,int> ex;
ex[inputString]++;
The debugger shows that int is initialized to zero correctly, is this a good guess?
Yes, values ββthat do not exist when accessed using operator[] are built by default. For numeric values, this is 0.
operator[]
However, you are looking for the count method:
count
bool hasElement = ex.count("element");