- 論壇徽章:
- 0
|
我把這個(gè)成員變量改成動(dòng)態(tài)開(kāi)辟。構(gòu)造函數(shù)通過(guò)了,可是往里面插數(shù)據(jù)時(shí)就報(bào)錯(cuò)了,到
pIndex[0].mapValue.insert(make_pair(1,"Pather1"));時(shí)就報(bào)錯(cuò)
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <vector>
using namespace std;
typedef struct
{
int nCollisionTimes;
map<int,string> mapValue;
}FIRST_INDEX_NODE;
typedef map<int,string>::iterator P_MAP;
int main()
{
FIRST_INDEX_NODE *pIndex = (FIRST_INDEX_NODE *)malloc(10*sizeof(FIRST_INDEX_NODE));
pIndex[0].mapValue.insert(make_pair(1,"Pather1"));
free(pIndex);
}
|
|
|