iterator it returns references pair using only these operations is often not worthwhile because the syntactic baggage can be expensive fortunatelythe map has an important extra operation that yields simple syntax the array-indexing operator is overloaded for maps as followsvaluetype operator[const keytype key )the semantics of operator[are as follows if key is present in the mapa reference to the corresponding value is returned if key is not present in the mapit is inserted with default value into the map and then reference to the inserted default value is returned the default value is obtained by applying zero-parameter constructor or is zero for the primitive types these semantics do not allow an accessor version of operator[]so operator[cannot be used on map that is constant for instanceif map is passed by constant referenceinside the routineoperator[is unusable the code snippet in figure illustrates two techniques to access items in map firstobserve that at line the left-hand side invokes operator[]thus inserting "patand double of value into the mapand returning reference to that double then the assignment changes that double inside the map to line outputs unfortunatelyline inserts "janand salary of into the map and then prints it this may or may not be the proper thing to dodepending on the application if it is important to distinguish between items that are in the map and those not in the mapor if it is important not to insert into the map (because it is immutable)then an alternate approach shown at lines to can be used there we see call to find if the key is not foundthe iterator is the endmarker and can be tested if the key is foundwe can access the second item in the pair referenced by the iteratorwhich is the value associated with the key we could also assign to itr->second ifinstead of const_iteratoritr is an iterator implementation of set and map +requires that set and map support the basic inserteraseand find operations in logarithmic worst-case time consequentlythe underlying implementation is balanced map salariessalaries"pat cout <salaries"pat<endlcout <salaries"jan<endlmap::const_iterator itritr salaries find"chris)ifitr =salaries endcout <"not an employee of this company!<endlelse cout second <endlfigure accessing values in map