????2????Java?У?TreeMap????????????????????????????????????????int??double???????????????????????????C++?У?????ε?????????д?????????????Java???????TreeMap????????????????????????????C++????????????????????п??????????????????????????????????????????????????????????????ж???copy??????????????????????????????????????????????????????????????????????????????????????????Java????

public class MyTest {
         private int _value;
         public MyTest(int value) {
             _value = value;
         }
   
         public static void main(String[] args) {
             TreeMap<Integer??MyTest> tm = new TreeMap<Integer??MyTest>();
             tm.put(5?? new MyTest(10));
             System.out.println("The count of the TreeMap is " + tm.size());
             Set<Entry<Integer??MyTest>> entries = tm.entrySet();
             Iterator<Entry<Integer??MyTest>> it = entries.iterator();
             while (it.hasNext()) {
                 Entry<Integer??MyTest> e = it.next();
                 System.out.printf("key = %d?? value = %d "??e.getKey().intValue()??e.getValue()._value);
             }
         }
     }
     //The count of the TreeMap is 1
     //key = 5?? value = 10

?????????Java???????????????????????????????????????C++????????????????????????????????μ????????C++?????????????????????????????????й?????????C++????????????

using namespace std;
     class MyTest
     {
     public:
         MyTest(int value) {
             _value = value;
         }
         ~MyTest() {}
     public:
         int getValue() const {
             return _value;
         }
     private:
         int _value;
     };
   
     int main()
     {
         map<int??MyTest*> m;
         m.insert(make_pair(5??new MyTest(10)));
         map<int??MyTest*>::iterator it = m.find(5);
         printf("The count of the map is %d. "??m.size());
         it = m.begin();
         for (; it != m.end(); ++it)
             printf("key = %d?? value = %d "??(*it).first??(*it).second->getValue());
         return 0;
     }
     //The count of the map is 1
     //key = 5?? value = 10

????????????????????????????Valgrind(Linux gcc)??BoundChecker(Visual C++)????????????????????????????MyTest???????????????????б?????????????????????й???????????????C++????

//?ú??????????????о??????????????
     #define RELEASE_MAP(Type1??Type2??variable)   
         do {
             map<Type1??Type2*>::iterator it = (variable).begin();
             for (; it != (variable).end(); ++it) 
                 delete (it->second);   
             (variable).clear();       
         } while(0)
           
     int main()
     {
         map<int??MyTest*> m;
         m.insert(make_pair(5??new MyTest(10)));
         map<int??MyTest*>::iterator it = m.find(5);
         printf("The count of the map is %d. "??m.size());
         it = m.begin();
         for (; it != m.end(); ++it)
             printf("key = %d?? value = %d "??(*it).first??(*it).second->getValue());
         RELEASE_MAP(int??MyTest??m);
         return 0;
     }

???????????????????????????????????????????????ж??????????й???????????????????????????????????????????????????????????????????????????й??????е????????????????????????й?????????C++?????д???Java?е?????????£????????????????????????????ò??????????????????C++??????????????????ò????????

?????????????????????????????????????????????????????????????????????????????