#include <iostream>
#include <unistd.h>
#include <string.h>
//#include "MapReader.h"
#include <map>
#include <string>
using namespace std;
class test
{
public:
test(int id,string strtest)
{
nId = id;
str = strtest;
str_buf = new char[50];
cout << sizeof(str.c_str()) <<endl;
strncpy(str_buf,str.c_str(),strlen(str.c_str()));
}
public:
int nId;
string str;
char * str_buf;
};
int main()
{
map<int,test*> myMap;
test * tt = new test(1002,"sssssssssssssd");
test * tt1 = new test(1003,"sssssssssssssd");
myMap.insert(map<int,test*>::value_type(tt->nId,tt));
myMap[tt1->nId] =tt;
map<int,test*>::iterator it = myMap.find(1002);
if(it!=myMap.end())
{
if(it->second!=NULL)
{
cout << myMap[1002]->str <<endl;
cout << myMap[1002]->str_buf <<endl;
}
}
cout << myMap[1003]->str_buf <<endl;
/* for(it=myMap.begin();it!=myMap.begin();it++)
{
cout << it->second.str <<endl;
}*/
/*for(int i=0;i<=10000;i++)
{
CMapReader mapReader = CMapReader("dead1.map");
mapReader.initMapFile();
int w = mapReader.getWidthFromMap();
int h = mapReader.getHeightFromMap();
int k = mapReader.getAlphaFromMap(700,526);
cout <<"before digHole" << " " << "i=" <<i <<" " << k <<endl;
for (int j=0;j<400;j++)
{
int k = mapReader.digHole("crater.map",509+2*j,526);
usleep(5);
}
k = mapReader.getAlphaFromMap(700,526);
cout <<"after digHole" << " " << i << k <<endl;
sleep(1);
cout <<"dddd" <<w <<" "<<h<<endl;
}*/
}
C++代碼記錄1--map
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.