Hello all
I'm having a problem using CMap with a structure. I'm mapping an ID number (long) to a pointer to a structure I've created:
struct myStruct
{
int prop1;
blah blah blah....
};
CMap<long, long&, myStruct*, myStruct*> myMap;
The problem occurs when I try to use SetAt() for the first time:
myStruct* pstruct;
int idx = 0;
while(yadda yadda....)
{
pstruct = new myStruct;
pstruct->prop1 = ...etc
myMap.SetAt(idx, pstruct); //goes wrong here
}
I get a user breakpoint error and then the process continues. SetAt() successfuly adds an element to the map, and every subsequent time I call it I get no error (at least until I RemoveAll() and start again), it's just the first time I use it. Am I not initialising something I sould be?
I've tried using CMapWordToPtr instead and that gives me the same problem.
The application is a console app that supports MFC (don't know if that's relevant)
any ideas?
Thanks in advance for any help
CMR
I'm having a problem using CMap with a structure. I'm mapping an ID number (long) to a pointer to a structure I've created:
struct myStruct
{
int prop1;
blah blah blah....
};
CMap<long, long&, myStruct*, myStruct*> myMap;
The problem occurs when I try to use SetAt() for the first time:
myStruct* pstruct;
int idx = 0;
while(yadda yadda....)
{
pstruct = new myStruct;
pstruct->prop1 = ...etc
myMap.SetAt(idx, pstruct); //goes wrong here
}
I get a user breakpoint error and then the process continues. SetAt() successfuly adds an element to the map, and every subsequent time I call it I get no error (at least until I RemoveAll() and start again), it's just the first time I use it. Am I not initialising something I sould be?
I've tried using CMapWordToPtr instead and that gives me the same problem.
The application is a console app that supports MFC (don't know if that's relevant)
any ideas?
Thanks in advance for any help
CMR