// Testingandtobe. cpp: defines the entry point of the console application. // # Include "stdafx. H "# include <iostream> # include <map> # include <string> using namespace STD; struct student {// virtual void fun () {Pointer Points to unknown crash void fun () {m_ I = 0; cout <"struct pointer calls the function test in the struct ,... m_ I = "<m_ I <Endl;} static int m_ I;}; int Student: m_ I = 0; typedef struct tagstudentinfo {int NID; string strname;} studentinfo, * pstudentinfo; Class sort {public: bool operator () (studentinfo const & _ A, studentinfo const & _ B) Const {If (_. NID <_ B. NID) return true; If (_. nid = _ B. NID) return _. strname. compare (_ B. strname) <0; return false ;}}; int _ tmain (INT argc, _ tchar * argv []) {/************** test function pointer *************/student * m_p = 0; m_p-> fun (); /************** test map container *************** // insert Data Map in array mode <int, string> mapstudent; mapstudent [3] = "student one"; mapstudent [1] = "student two"; mapstudent [2] = "student three"; Map <int, string >:: ite Rator ITER; For (iter = mapstudent. Begin (); iter! = Mapstudent. end (); ITER ++) {cout <"insert test... "<ITER-> second <Endl ;}// test the Map <int, string >:: iterator iterr; iterr = mapstudent. lower_bound (2); {cout <"findtest... "<iterr-> second <Endl;} iterr = mapstudent. upper_bound (2); {cout <"findtest... "<iterr-> second <Endl;} pair <Map <int, string >:: iterator, Map <int, string >:: iterator> mappair; mappair = mapstudent. pai_range (2); If (mappair. first = mappair. second) {cout <" Donot find "<Endl;} else {cout <" findtest... find "<Endl ;}// insert function inserts data/* Map <int, string> mapstudent; pair <Map <int, string >:: iterator, bool> insert_pair; insert_pair = mapstudent. insert (pair <int, string> (1, "student one"); If (insert_pair.second = true) {cout <"insert successfully" <Endl ;} else {cout <"insert failure" <Endl;} insert_pair = mapstudent. insert (pair <int, string> (2, "student two"); If (in Sert_pair.second = true) {cout <"insert successfully" <Endl;} else {cout <"insert failure" <Endl;} Map <int, string> :: iterator ITER; For (iter = mapstudent. begin (); iter! = Mapstudent. end (); ITER ++) {cout <ITER-> first <"" <ITER-> second <Endl ;} ********* * **************** // use the student information to map the score to int nsize; map <studentinfo, Int, sort> mapstudentt; Map <studentinfo, Int, sort >:: iterator iterrr; studentinfo. nid = 1; studentinfo. strname = "student_one"; mapstudentt. insert (pair <studentinfo, int> (studentinfo, 90); studentinfo. Nid = 2; studentinfo. strname = "student_two"; mapstudentt. insert (pair <studentinfo, int> (studentinfo, 80); For (iterrr = mapstudentt. begin (); iterrr! = Mapstudentt. End (); iterrr ++) cout <"test order..." <iterrr-> second <Endl; return 0 ;}