CMapStringToOb::RemoveKey
제공 된 키에 해당 맵 항목을 찾습니다. 키가 있으면 다음 항목을 제거 합니다.
BOOL RemoveKey(
LPCTSTR key
);
매개 변수
- key
매핑 조회에 사용 되는 문자열을 지정 합니다.
반환 값
항목을 찾아 제거 하는 경우에 0이 아닌. 그렇지 않으면 0입니다.
설명
이 경우 메모리 누수가 발생할 수 있습니다는 CObject 개체가 다른 곳에서 삭제 됩니다.
다음 표에서 다른 멤버와 비슷한 함수를 보여 줍니다. CMapStringToOb::RemoveKey.
클래스 |
멤버 함수 |
---|---|
BOOL RemoveKey (void *key); |
|
BOOL RemoveKey (void *key); |
|
BOOL RemoveKey (LPCTSTRkey); |
|
BOOL RemoveKey (LPCTSTRkey); |
|
BOOL RemoveKey (WORDkey); |
|
BOOL RemoveKey (WORDkey); |
예제
참조 하십시오 CObList::CObList 에 CAge 모든 컬렉션 예제에 사용 되는 클래스입니다.
CMapStringToOb map;
map.SetAt(_T("Bart"), new CAge(13));
map.SetAt(_T("Lisa"), new CAge(11));
map.SetAt(_T("Homer"), new CAge(36));
map.SetAt(_T("Marge"), new CAge(35));
map.RemoveKey(_T("Lisa")); // Memory leak: CAge object not
// deleted.
#ifdef _DEBUG
afxDump.SetDepth(1);
afxDump << _T("RemoveKey example: ") << &map << _T("\n");
#endif
이 프로그램의 결과 다음과 같습니다.
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
요구 사항
헤더: afxcoll.h