CMapStringToOb::RemoveAll

void RemoveAll( );

说明:
删除映射中所有的元素,并销毁CString键对象。不过,每一个键参考的CObject对象不会被销毁。如果没有确保已经销毁了CObject对象,那么RemoveAll函数可能导致内存出现空洞。
如果映射为空,该函数也会正确运行。

示例:
请参阅CObList::CObList,了解所有收集示例中使用的CAge类。
// example for CMapStringToOb::RemoveAll
{
  CMapStringToOb map;
  CAge age1( 13 ); // Two objects on the stack
  CAge age2( 36 );
  map.SetAt( "Bart", &age1 );
  map.SetAt( "Homer", &age2 );
  ASSERT( map.GetCount() == 2 );
  map.RemoveAll(); // CObject pointers removed; objects not removed.
  ASSERT( map.GetCount() == 0 );
  ASSERT( map.IsEmpty() );
} // The two CAge objects are deleted when they go out of scope.

请参阅:CMapStringToOb::RemoveKey