//==============将数据存储到 CMAP中
int xxx=atoi(strc);
m_map.SetAt(xxx,rit);
根据m_dat把对应的ch查询出来
m_map.Lookup(m_dat,ch);

解决方案 »

  1.   

    给你举个STL里面的map的例子,跟CMap用法应该一样的。
    #include <map>
    #include <string>
    using namespace std;
    ...
    map<string, string> namemap;//增加
    namemap["岳不群"]="华山派掌门人,人称君子剑";
    namemap["张三丰"]="武当掌门人,太极拳创始人";
    namemap["东方不败"]="第一高手,葵花宝典";
    ...//查找。。
    if(namemap.find("岳不群") != namemap.end()){
            ...
    }
      

  2.   

    复制 粘贴
    CMap<int,int,CPoint,CPoint> myMap;   // Add 10 elements to the map.
       for (int i=0;i < 10;i++)
          myMap.SetAt( i, CPoint(i, i) );   // Remove the elements with even key values.
       POSITION pos = myMap.GetStartPosition();
       int    nKey;
       CPoint pt;
       while (pos != NULL)
       {
          myMap.GetNextAssoc( pos, nKey, pt );      if ((nKey%2) == 0)
             myMap.RemoveKey( nKey );
       }#ifdef _DEBUG
        afxDump.SetDepth( 1 );
        afxDump << "myMap: " << &myMap << "\n";
    #endif
      

  3.   

    CMap<int,int,CPoint,CPoint> myMap;
       int i;   myMap.InitHashTable( 257 );   // Add 10 elements to the map.
       for (i=0;i < 200;i++)
          myMap[i] = CPoint(i, i);   // Remove the elements with even key values.
       CPoint pt;
       for (i=0; myMap.Lookup( i, pt ) ;i+=2)
       {
          myMap.RemoveKey( i );
       }