Export (0) Print
Expand All

CMap::operator [ ] 

A convenient substitute for the SetAt member function.


VALUE& operator[](
      ARG_KEY key 
);

Parameters

VALUE

Template parameter specifying the type of the map value.

ARG_KEY

Template parameter specifying the type of the key value.

key

The key used to retrieve the value from the map.

Thus it can be used only on the left side of an assignment statement (an l-value). If there is no map element with the specified key, then a new element is created.

There is no "right side" (r-value) equivalent to this operator because there is a possibility that a key may not be found in the map. Use the Lookup member function for element retrieval.

See the example for CMap::Lookup.

Community Additions

ADD
Show:
© 2014 Microsoft