CMapStringToOb::RemoveKey

Syntax

BOOL RemoveKey( const char* key );

Parameters

key

The string used for map lookup.

Remarks

Looks up the map entry corresponding to the supplied key; then, if the key is found, removes the entry. This can cause memory leaks if the CObject object is not deleted elsewhere.

Return Value

TRUE if the entry was found and successfully removed; otherwise FALSE.

Example

CMapStringToOb map;

map.SetAt( "Bart", new CAge( 13 ) );

map.SetAt( "Lisa", new CAge( 11 ) );

map.SetAt( "Homer", new CAge( 36 ) );

map.SetAt( "Marge", new CAge( 35 ) );

map.RemoveKey( "Lisa" ); // memory leak: age object not deleted

#ifdef _DEBUG

afxDump.SetDepth( 1 );

afxDump << "RemoveKey example: " << &map << "\\n";

#endif

The results from this program are as follows:

RemoveKey example: A CMapStringToOb with 3 elements

[Marge] = a CAge at $49A0 35

[Homer] = a CAge at $495E 36

[Bart] = a CAge at $4634 13

See Also

CMapStringToOb::RemoveKey