- 论坛徽章:
- 0
|
我把这个成员变量改成动态开辟。构造函数通过了,可是往里面插数据时就报错了,到
pIndex[0].mapValue.insert(make_pair(1,"Pather1"));时就报错
#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);
}
|
|
|