Microsoft Foundation Classes (mfc.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
CMapStringToOb::SetAt
CMapStringToOb                              Up Contents Index Back
──Microsoft Foundation Classes──────────────────────────────────────────────
 
  void SetAt( const char* key, CObject* newValue )
  throw( CMemoryException );
 
  Parameter   Description
 
  <key>       Specifies the string that is the key of the new element.
 
  <newValue>  Specifies the CObject pointer that is the value of the new
              element.
 
  Remarks
 
  The primary means to insert an element in a map. First, the key is
  looked up. If the key is found, then the corresponding value is changed;
  otherwise, a new key-value element is created.
 
  Example
 
  CMapStringToOb map;
  CAge* pa;
 
  map.SetAt( "Bart", new CAge( 13 ) );
  map.SetAt( "Lisa", new CAge( 11 ) ); // Map contains 2 elements
  if( map.Lookup( "Lisa", pa ) )
  { // CAge 12 pointer replaces CAge 11 pointer
      map.SetAt( "Lisa", new CAge( 12 ) );
      delete pa;  // Must delete CAge 11 to avoid memory leak
  }
 
  The results from this program are as follows:
 
  before Lisa's birthday: A CMapStringToOb with 2 elements
      [Lisa] = a CAge at $493C 11
      [Bart] = a CAge at $4654 13
  after Lisa's birthday: A CMapStringToOb with 2 elements
      [Lisa] = a CAge at $49C0 12
      [Bart] = a CAge at $4654 13
 
  See Also
 
  CMapStringToOb::Lookup, CMapStringToOb::operator []
 
 
                                     -♦-