Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User breakpoint when using CMap

Status
Not open for further replies.

CMR

Programmer
Apr 30, 2002
76
AU
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top