C++ problem

BenShums's Avatar, Join Date: Jan 2008
Newbie Member
Okay, so, I know just posted a thread, but I promise I won't post anymore for a week or two.

With that out of the way, here is my problem....

When I run this code in Visual Studio 2008's debugger,

string str = "string";
int num = 28;
multimap<string,int> mm;
mm.insert(pair<string,int>(str, num));

After mm.insert(pair<string,int>(str,num)); str gets set to "bad pointer", and num becomes a really humongous number. In addition my debugger shows that mm contains a thousand keys labeled "error". It's really weird because I #included <map>, and declared it perfectly and everything.

Do you think it has something to do with my settings?


~Ben Shumway
BenShums's Avatar, Join Date: Jan 2008
Newbie Member
Okay, so I spent some time away from the computer to let my mind refresh. When I came back, I realized that in the code

1: string str = "string";
2: int num = 28;
3: multimap<string,int> mm;
4: mm.insert(pair<string,int>(str, num));

str becomes a bad-pointer not when when it's inserted inside of mm, but when it's created on line 1.

Why is this? I'm declaring the string perfectly fine, and I'm #including <string>.

Any ideas would be mich appreciated.


~Ben S.