Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   C++ problem (http://www.go4expert.com/forums/cpp-problem-t8070/)

BenShums 2Jan2008 09:29

C++ problem
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 2Jan2008 12:55

Re: C++ problem
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.

All times are GMT +5.5. The time now is 19:23.