[Cs3] indexing a non-existent element in a map

Mikhail Nesterenko mikhail at cs.kent.edu
Thu Sep 21 22:26:28 EDT 2023


CS3 students,

Apparently, even indexing a non-existent element for reading inserts
it into a map. That is


   cout << mymap['x'];

Will insert a new element with key 'x' into mymap.

My info here:

  https://cplusplus.com/reference/map/map/operator[]/

Thanks,
-- 
Mikhail


More information about the cs3 mailing list